Get the reason of “you can’t install the app on your device”

Today, when I package an app, and try to install on the device, it report the following error:

Get the reason of “you can’t install the app on your device”

Today, when I package an app, and try to install on the device, it report the following error:you can't install the app on your device

There aren’t any information about the error, so for the user, we don’t know what to do, I am try to get the reason of the error.

Get the error message with adb

We can get the error with adb, after connect to the device with adb, we can use two methods to get the error message.

Install the app with pm

Upload the apk to the device, then use pm install command to install the application, it will report the error, the example are like below:adb -s <serialId> push <name_of_apk>.apk /data/local/tmp/
adb -s <serialId> shell
# The following command run on shell
cd /data/local/tmp
pm install <name_of_apk>.apk# Example of my error
Failure [INSTALL_FAILED_VERSION_DOWNGRADE]

My failed message is my version code is less than the app installed on my device.

Install from device

We can use logcat to get the logs, but on the device, we just use logcat without any parameter, it will output a lot of messages, it’s not easy to get the error message, we can filter the error message of PackageManager like below:logcat | grep PackageManager# Example of my error
07-28 06:35:35.259  1666  2017 W PackageManager: Downgrade detected: Update version code 190 is older than current 191

With this message, it’s more clear that apk version code 190 is less than the code on the device 191.

Thanks for your reading, if you encounter the same error, hope this article can give you some help.