Setting the install vendor of an app

Oct 6, 2014 · 2 min read
Image for post
Image for post

In a recent project, we wanted to add an alternative payment method for in-app purchases for installs outside Google Play. In correspondence with the Google Play ToS, the alternative payment method should only be available if the app was installed outside of Google Play. The code was straightforward enough:

PackageManager packageManager = getPackageManager();
String installerName = packageManager.getInstallerPackageName(getPackageName());
if (installerName != null) {
if (installerName.equals("")) {
mHasGooglePlay = true;

Testing this, however, turned out to be quite tricky. Who wants to wait for hours for the alpha version to appear on Google Play? The following adb trick sets the install vendor of an app:

adb push app.apk /data/local/tmp/app.apk
adb shell pm install -i "" -r /data/local/tmp/app.apk
adb shell rm /data/local/tmp/app.apk

This trick works for both debug and release APKs.

Executing the various commands to set the install vendor and confirm that it's set
Executing the various commands to set the install vendor and confirm that it's set
Set the install vendor and confirm that it’s set

For those familiar with installing apps through adb, all you need to do is provide the -i argument. Unfortunately, it needs to be a local path on the device, and doesn't work in conjunction with pushing from your local machine. The three commands above effectively (1) upload the APK to external storage on the device, (2) install it through the Package Manager with specifying the installation package, and (3) concludes by deleting the temporary file. To confirm that this has worked, list the packages using the Package Manager:

adb shell pm list packages -i [packagename]

If all has gone well, you should see this output:


Updated May 16, 2018: Since Android P you can no longer push the apk to /sdcard/app/apk, you will need to push to /data/local/tmp/app.apk instead.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store