Permission Denied for downloaded APK when performing Upgrade in Android 11

// Expert user has replied.
Z ZWTG ZWTG 1 year 7 months ago
26 2 0

I have been attempting to test my Android application to ensure it supports Android 11 but have been having trouble with our pre-existing In-App upgrade process.

We make use of EMDK to call an upgrade instruction after downloading to our applications storage:

Where apkPath = Path.Combine(context.GetExternalFilesDir(null).AbsolutePath, fileName);

In Android 10 and prior, this instruction would succeed. However for Android 11, we are getting an error "INSTALL_FAILED_INVALID_URI", even though the path is identical.

Investigating via Logcat i discovered the following logs:
10-05 00:49:03.079 6970 7019 I MXStorageManager: Received Path: /sdcard/Android/data/{PACKAGENAME}/files/{PACKAGENAME}.apk
10-05 00:49:03.079 6970 7019 I MXStorageManager: Returned Path: /sdcard/Android/data/{PACKAGENAME}/files/{PACKAGENAME}.apk
10-05 00:49:03.081 2954 2990 W ziparchive: Unable to open '/sdcard/Android/data/{PACKAGENAME}/files/{PACKAGENAME}.apk': Permission denied
10-05 00:49:03.081 2954 2990 E nstallerservic: Failed to open APK '/sdcard/Android/data/{PACKAGENAME}/files/{PACKAGENAME}.apk' I/O error
10-05 00:49:03.081 2954 2990 W System.err: android.content.pm.PackageParser$PackageParserException: Failed to parse /sdcard/Android/data/{PACKAGENAME}/files/{PACKAGENAME}.apk
10-05 00:49:03.082 2954 2990 W System.err: at android.content.pm.PackageParser.parseApkLiteInner(PackageParser.java:1449)
10-05 00:49:03.082 2954 2990 W System.err: at android.content.pm.PackageParser.parseApkLite(PackageParser.java:1420)
10-05 00:49:03.082 2954 2990 W System.err: at android.content.pm.PackageParser.parseMonolithicPackageLite(PackageParser.java:935)
10-05 00:49:03.082 2954 2990 W System.err: at android.content.pm.PackageParser.parsePackageLite(PackageParser.java:928)
10-05 00:49:03.082 2954 2990 W System.err: at c.b.b.a.c$a.onTransact(:11)
10-05 00:49:03.082 2954 2990 W System.err: at android.os.Binder.execTransactInternal(Binder.java:1154)
10-05 00:49:03.082 2954 2990 W System.err: at android.os.Binder.execTransact(Binder.java:1123)

Why does EMDK not have permission to install this apk? I can manually install without issue, and this works for older versions of Android.
How do I resolve this for Android 11?

Please register or login to post a reply

2 Replies

J James Swinton-Bland

Hi,

I think this is an issue w/ Scoped Storage in A11. Because you're storing your file in your applications scoped storage, the EMDK can't access the file for security reasons. We've a blog with some more detail here.

I think you have a couple options:

  • Store the APK in the /enterprise folder. This doesn't require any additional permissions, however, the file will persist after an enterprise reset so make sure to delete it if you don't need it any more.
  • Use any other shared storage location (E.g. "/sdcard/") by requesting the MANAGE_EXTERNAL_STORAGE permission. There's a few drawbacks to this option, but the main one is that your app can't be distributed via the public playstore (bar a few very small exceptions)

 

R Richard Venderbosch

You can also use "/data/tmp/public/".
See "Device File Location Rules" on https://techdocs.zebra.com/emdk-for-android/11-0/mx/powermgr/.

CONTACT
Can’t find what you’re looking for?