Failure [INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE]
Asked Answered
P

3

13

I entered the command below in the CMD and the command returned the error below the command.

Command:

phonegap run android --verbose --stacktrace

Error:

ERROR: Failed to launch application on device:

ERROR: Failed to install apk to device: pkg: /data/local/tmp/MainActivity-debug.apk

Failure [INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE]

Pengelly answered 14/1, 2016 at 14:4 Comment(0)
O
32

The problem there, is that you are attempting to install a version of your APK that is LESS than what is already on your device.

Uninstalling will certainly fix that problem for you.

ADB allows more flexibility adb install -r -d <apk path>, but I am not sure that Phonegap has that functionality.

adb install [-lrtsdg] <file>
   - push this package file to the device and install it
     (-l: forward lock application)
     (-r: replace existing application)
     (-t: allow test packages)
     (-s: install application on sdcard)
     (-d: allow version code downgrade)
     (-g: grant all runtime permissions)

Update:

It turns out that was not the correct error message for downgrading the App version. Infact, it is something completely separate. I found this link that accurately explains the situation:

tl;dr You can't fool the new Android 6 permissions model by first publishing an APK with targetSdk 23 which will grant all permissions runtime and then publishing a new version with targetSdk 22 or less. You'll get an INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE error.

I was working on an app with targetSdk 23 (Android 6 Marshmallow) when it hit me that it possibly could be a security issue with the new Android permission model. Android 6 devices approves all permission on install time and then the user has to approve them whenever the app asks for the permission. What if the user installed the app - auto granting all permissions - and then it didn't ask for using them, and then afterwards the app was updated with the same permissions, but with a lower targetSdk?

I spent a couple minutes creating an app that targeted SDK level 23 and added a fine location permission (ACCESS_FINE_LOCATION). Then I installed and ran the app. The app didn't ask for permission to access the location manager. Then I set the SDK level to 22 and tried to install the app. Luckily it wasn't able to install. I got an error saying Failure [INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE].

Osbourne answered 14/1, 2016 at 14:10 Comment(6)
Where does the -r stand for? I can't find it in the android debug bridge documentation of developer.android.com. Could you also say what you mean with 'version'. It's a little vague.Pengelly
I updated my question to reflex the option meaning. By version I mean your App version. If you have App version 3 installed, and attempt to install App version 2. It will not allow it without hte degradation flag.Osbourne
I tested your theory. I changed my app version from 2 to 1 and I got a different error: [INSTALL_FAILED_VERSION_DOWNGRADE] so I am confused. Does this error mean the same as the one I had before: [INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE]? I am curious what the difference is between those errors.Pengelly
It looks like I was wrong. The error message is quite similar. I found the real reason though. Ill edit my answer.Osbourne
The -d option only works for debuggable apks. From adb -help: "-d: allow version code downgrade (debuggable packages only)"Marrowbone
Since the first section about INSTALL_FAILED_VERSION_DOWNGRADE is misleading to this issue, would you edit and restructure the answer so that the second section about INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE is explained first, then perhaps additionally mentioning "not to be confused with INSTALL_FAILED_VERSION_DOWNGRADE when [...]"Floatfeed
P
10

Solution:

I managed to get rid of the error by uninstalling my app from my device.

Cause:

What probably caused the error is that I updated my Android SDK with SDK Manager.

Pengelly answered 14/1, 2016 at 14:4 Comment(0)
R
0

I got this error in VS2015 using TACO and debugging for Android using a particular emulator profile: VS Emulator 10.1" Marshmallow (6.0.0) XHDPI Tablet. The project I was working on was installed as an app on that particular profile because I had been using it for debugging. I solved the problem by uninstalling and reinstalling that particular profile: Tools -> Visual Studio Emulator for Android -> Uninstall profile. The reinstalled profile no longer contained my app and the error went away. It's the VS Emulator equivalent of uninstalling the app from a remote device, I guess.

Relevance answered 1/3, 2016 at 6:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.