Xamarin-android: Mono.AndroidTools.InstallFailedException: Failure [INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2]

Created on 8 Aug 2020  路  4Comments  路  Source: xamarin/xamarin-android

After update to latest Visual Studio for Mac the Android app is not deployed to the device anymore.
The previous version worked well.

Steps to Reproduce

  1. Try to run the app on the Emulator

Expected Behavior

The app runs

Actual Behavior

Deployment failed with error:

    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010:  Deployment failed
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010: Mono.AndroidTools.InstallFailedException: Failure [INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2]
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010:   at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess (System.String output, System.String packageName) [0x00151] in /Users/builder/azdo/_work/22/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/Internal/AdbOutputParsing.cs:344 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010:   at Mono.AndroidTools.AndroidDevice+<>c__DisplayClass97_0.<InstallPackage>b__0 (System.Threading.Tasks.Task`1[TResult] t) [0x00016] in /Users/builder/azdo/_work/22/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/AndroidDevice.cs:784 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010:   at System.Threading.Tasks.ContinuationTaskFromResultTask`1[TAntecedentResult].InnerInvoke () [0x00024] in <b62523977edc47f990e8bfd12c39abb8>:0 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010:   at System.Threading.Tasks.Task.Execute () [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2319 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010: --- End of stack trace from previous location where exception was thrown ---
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010: 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010:   at AndroidDeviceExtensions.PushAndInstallPackage (Mono.AndroidTools.AndroidDevice device, System.String apkFile, System.String packageName, System.Boolean reinstall, Mono.AndroidTools.Adb.AdbProgressReporter notifyProgress, System.Threading.CancellationToken token) [0x00188] in /Users/builder/azdo/_work/22/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Devices/AndroidDeviceExtensions.cs:187 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010:   at AndroidDeviceExtensions.PushAndInstallPackage (Mono.AndroidTools.AndroidDevice device, System.String apkFile, System.String packageName, System.Boolean reinstall, Mono.AndroidTools.Adb.AdbProgressReporter notifyProgress, System.Threading.CancellationToken token) [0x003ce] in /Users/builder/azdo/_work/22/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Devices/AndroidDeviceExtensions.cs:203 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010:   at Xamarin.AndroidTools.AndroidDeploySession.InstallPackage () [0x00517] in /Users/builder/azdo/_work/22/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:469 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010:   at Xamarin.AndroidTools.AndroidDeploySession.RunAsync (System.Threading.CancellationToken token) [0x003ae] in /Users/builder/azdo/_work/22/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:221 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010:   at Xamarin.AndroidTools.AndroidDeploySession.RunLoggedAsync (System.Threading.CancellationToken token) [0x0002f] in /Users/builder/azdo/_work/22/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:123 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010: Mono.AndroidTools.InstallFailedException: Failure [INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2]
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010:   at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess (System.String output, System.String packageName) [0x00151] in /Users/builder/azdo/_work/22/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/Internal/AdbOutputParsing.cs:344 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010:   at Mono.AndroidTools.AndroidDevice+<>c__DisplayClass97_0.<InstallPackage>b__0 (System.Threading.Tasks.Task`1[TResult] t) [0x00016] in /Users/builder/azdo/_work/22/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/AndroidDevice.cs:784 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010:   at System.Threading.Tasks.ContinuationTaskFromResultTask`1[TAntecedentResult].InnerInvoke () [0x00024] in <b62523977edc47f990e8bfd12c39abb8>:0 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010:   at System.Threading.Tasks.Task.Execute () [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2319 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010: --- End of stack trace from previous location where exception was thrown ---
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010: 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010:   at AndroidDeviceExtensions.PushAndInstallPackage (Mono.AndroidTools.AndroidDevice device, System.String apkFile, System.String packageName, System.Boolean reinstall, Mono.AndroidTools.Adb.AdbProgressReporter notifyProgress, System.Threading.CancellationToken token) [0x00188] in /Users/builder/azdo/_work/22/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Devices/AndroidDeviceExtensions.cs:187 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010:   at AndroidDeviceExtensions.PushAndInstallPackage (Mono.AndroidTools.AndroidDevice device, System.String apkFile, System.String packageName, System.Boolean reinstall, Mono.AndroidTools.Adb.AdbProgressReporter notifyProgress, System.Threading.CancellationToken token) [0x003ce] in /Users/builder/azdo/_work/22/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Devices/AndroidDeviceExtensions.cs:203 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010:   at Xamarin.AndroidTools.AndroidDeploySession.InstallPackage () [0x00517] in /Users/builder/azdo/_work/22/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:469 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010:   at Xamarin.AndroidTools.AndroidDeploySession.RunAsync (System.Threading.CancellationToken token) [0x003ae] in /Users/builder/azdo/_work/22/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:221 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(618,2): error ADB0010:   at Xamarin.AndroidTools.AndroidDeploySession.RunLoggedAsync (System.Threading.CancellationToken token) [0x0002f] in /Users/builder/azdo/_work/22/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:123 

Version Information

Visual Studio Community 2019 for Mac
Version 8.7 (build 2037)
Installation UUID: 070aa298-78d0-40a9-bbb4-b5e662ad1bbf
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

Package version: 612000089

Mono Framework MDK
Runtime:
Mono 6.12.0.89 (2020-02/e59c1cd70f4) (64-bit)
Package version: 612000089

Roslyn (Language Service)
3.7.0-6.20371.12+917b9dfae12e3b6cb266a3c062fb20a1e9d5fb06

NuGet
Version: 5.7.0.6702

.NET Core SDK
SDK: /usr/local/share/dotnet/sdk/3.1.302/Sdks
SDK Versions:
3.1.302
3.1.301
3.1.300
3.1.202
3.1.200
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin/Sdks

.NET Core Runtime
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
3.1.6
3.1.5
3.1.4
3.1.2
2.1.20
2.1.19
2.1.18
2.1.17

Xamarin.Profiler
Version: 1.6.13.11
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater
Version: 11

Xamarin.Android
Version: 11.0.0.3 (Visual Studio Community)
Commit: xamarin-android/d16-7/aca845b
Android SDK: /Users/seifer/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
None installed

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 30.0.1
SDK Build Tools Version: 29.0.3

Build Information:
Mono: 83105ba
Java.Interop: xamarin/java.interop/d16-7@1f3388a
ProGuard: Guardsquare/proguard/proguard6.2.2@ebe9000
SQLite: xamarin/sqlite/3.32.1@1a3276b
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-7@017078f

Microsoft OpenJDK for Mobile
Java SDK: /Users/seifer/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Android SDK Manager
Version: 16.7.0.13
Hash: 8380518
Branch: remotes/origin/dev/jmt/d16-7readconfig~2
Build date: 2020-07-23 22:38:02 UTC

Android Device Manager
Version: 16.7.0.18
Hash: 4b44bc1
Branch: remotes/origin/d16-7
Build date: 2020-07-23 22:38:26 UTC

Apple Developer Tools
Xcode 11.6 (16141)
Build 11E708

Xamarin.Mac
Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version.

Xamarin.iOS
Version: 13.20.2.2 (Visual Studio Community)
Hash: 817b6f72a
Branch: d16-7
Build date: 2020-07-18 18:45:00-0400

Xamarin Designer
Version: 16.7.0.492
Hash: f5afe667d
Branch: remotes/origin/d16-7-vsmac
Build date: 2020-07-10 18:42:54 UTC

Build Information
Release ID: 807002037
Git revision: b7706774ff5a1b761a7eb7f2d116d0d2c29ad87c
Build date: 2020-07-31 04:14:15-04
Build branch: release-8.7
Xamarin extensions: b7706774ff5a1b761a7eb7f2d116d0d2c29ad87c

Operating System
Mac OS X 10.15.6
Darwin 19.6.0 Darwin Kernel Version 19.6.0
Sun Jul 5 00:43:10 PDT 2020
root:xnu-6153.141.1~9/RELEASE_X86_64 x86_64

Log File

08-08 18:05:25.463  8659  8659 I abb     : StartCommandInProcess(73657474696e67730067657400656e61 settings.get.ena [truncated])
08-08 18:05:25.469  8659  8659 I abb     : StartCommandInProcess(7061636b61676500696e7374616c6c00 package.install. [truncated])
08-08 18:05:25.459  2564  2564 W Binder:2564_A: type=1400 audit(0.0:39): avc: denied { getopt } for scontext=u:r:system_server:s0 tcontext=u:r:shell:s0 tclass=unix_stream_socket permissive=0
08-08 18:05:25.459  2564  2564 W Binder:2564_A: type=1400 audit(0.0:40): avc: denied { getopt } for scontext=u:r:system_server:s0 tcontext=u:r:shell:s0 tclass=unix_stream_socket permissive=0
08-08 18:05:25.459  2564  2564 W Binder:2564_A: type=1400 audit(0.0:41): avc: denied { getopt } for scontext=u:r:system_server:s0 tcontext=u:r:shell:s0 tclass=unix_stream_socket permissive=0
08-08 18:05:25.459  1904  1904 W adbd    : type=1400 audit(0.0:42): avc: denied { shutdown } for scontext=u:r:adbd:s0 tcontext=u:r:shell:s0 tclass=unix_stream_socket permissive=0
08-08 18:05:27.629  2564  2564 W Binder:2564_A: type=1400 audit(0.0:43): avc: denied { getopt } for scontext=u:r:system_server:s0 tcontext=u:r:shell:s0 tclass=unix_stream_socket permissive=0
08-08 18:05:27.894  2564  2600 I system_server: Background concurrent copying GC freed 97913(3920KB) AllocSpace objects, 17(1476KB) LOS objects, 33% free, 11MB/17MB, paused 1.147ms total 232.468ms
08-08 18:05:28.941  2564  3086 E NativeLibraryHelper: Library 'libflutter.so' is compressed - will not be able to open it directly from apk.
--------- beginning of system
08-08 18:05:28.941  2564  3086 W NativeHelper: Failure copying native libraries [errorCode=-2]
08-08 18:05:28.941  2564  3086 E PackageInstallerSession: Commit of session 659073752 failed: Failed to extract native libraries, res=-2
08-08 18:05:28.979  2564  2564 W Binder:2564_A: type=1400 audit(0.0:44): avc: denied { getopt } for scontext=u:r:system_server:s0 tcontext=u:r:shell:s0 tclass=unix_stream_socket permissive=0
08-08 18:05:28.979  2564  2564 I chatty  : uid=1000 system_server identical 1 line
08-08 18:05:28.979  2564  2564 W Binder:2564_A: type=1400 audit(0.0:46): avc: denied { getopt } for scontext=u:r:system_server:s0 tcontext=u:r:shell:s0 tclass=unix_stream_socket permissive=0
08-08 18:05:28.989  1904  1904 W adbd    : type=1400 audit(0.0:47): avc: denied { shutdown } for scontext=u:r:adbd:s0 tcontext=u:r:shell:s0 tclass=unix_stream_socket permissive=0
08-08 18:05:29.840  4910  4985 I MicroDetectionWorker: #startMicroDetector [speakerMode: 0]
08-08 18:05:29.842  4910  4985 W ErrorReporter: reportError [type: 211, code: 393244, bug: 0]: errorCode: 393244, engine: 0
08-08 18:05:29.844  4910  4985 I MicroDetector: Keeping mic open: false
08-08 18:05:29.844  4910  4985 I MicroDetectionWorker: #onError(false)
App Runtime

Most helpful comment

_Release status update_

A new Preview version of Xamarin.Android has now been published that includes the fix for this item. The fix is not yet included in a Release version. I will update this item again when a Release version is available that includes the fix.

Fix included in Xamarin.Android SDK version 11.1.0.3.

Fix included on Windows in Visual Studio 2019 version 16.8 Preview 3. To try the Preview version that includes the fix, check for the latest updates in Visual Studio Preview.

Fix included on macOS in Visual Studio 2019 for Mac version 8.8 Preview 3. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel.

All 4 comments

Well, adding android:extractNativeLibs="true" actually fixes the issue (see https://stackoverflow.com/a/55186445/4478393).

I'm not sure why the build works without it on the previous version (Xamarin.Android 10.3.1.4) but started to fail on the newer one (Xamarin.Android 11.0.0.3).

Also, I'm not sure about the consequences...

Closing the issue, as there is a workaround.

You also run into issue #4983

_Release status update_

A new Preview version of Xamarin.Android has now been published that includes the fix for this item. The fix is not yet included in a Release version. I will update this item again when a Release version is available that includes the fix.

Fix included in Xamarin.Android SDK version 11.1.0.3.

Fix included on Windows in Visual Studio 2019 version 16.8 Preview 3. To try the Preview version that includes the fix, check for the latest updates in Visual Studio Preview.

Fix included on macOS in Visual Studio 2019 for Mac version 8.8 Preview 3. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel.

_Release status update_

A new Release version of Xamarin.Android has now been published that includes the fix for this item.

Fix included in Xamarin.Android SDK version 11.1.0.17.

Fix included on Windows in Visual Studio 2019 version 16.8. To get the new version that includes the fix, check for the latest updates or install the most recent release from https://visualstudio.microsoft.com/downloads/.

Fix included on macOS in Visual Studio 2019 for Mac version 8.8. To get the new version that includes the fix, check for the latest updates on the Stable updater channel.

Was this page helpful?
0 / 5 - 0 ratings