Targeting SDK Android Q results in Failed to finalize session : INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2

failure (install_failed_no_matching_abis: failed to extract native libraries, res=-113)
install failed no matching abis failed to extract native libraries res 113
extractnativelibs
install_failed_no_matching_abis: failed to extract native libraries, res=-113 flutter
error failed to open apk invalid offset
failure (install_failed_invalid_apk: package couldn t be installed in)
android:debuggable true
install_failed_invalid_apk apktool

Once I switch my target api to 'Q' I cannot install the APK on Android Q Emulator. I get error:

Failed to finalize session : INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2

Android Studio (v3.3.2) recommends I uninstall apk first. I tried uninstalling apk and I still get the same error. App work if I downgrade target api to 28.

This happens because of an issue with zipalign, see - https://issuetracker.google.com/issues/37045367. You need to set extractNativeLibs in your Application Tag on AndroidManifest.xml

<application
        android:allowBackup="false"
        android:label="@string/app_name"
        android:extractNativeLibs="true"
...
>

If you are using adb to install the apk try adding -t flag

adb install -t <path-to-apk>

Targeting SDK Android Q results in Failed to finalize , Targeting SDK Android Q results in Failed to finalize session : INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2. Questions: Once I switch my target api to ‘Q’ I cannot install the APK on Android Q Emulator. I get error: Failed to finalize session : INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2 Android Studio (v3.3.2) recommends I uninstall apk first.

If you want android:extractNativeLibs="false", use zipalign with -p key in order to page align ELFs within ZIP:

zipalign -p 4 app.apk app-aligned.apk

Failure [INSTALL_FAILED_INVALID_APK], Targeting SDK Android Q results in Failed to finalize session : INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2. 05-11 18:51. Teams. Q&A for Work. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information.

I also got this error in AWS Device Farm. Turns out they have sdk version 21 installed and my minSdkVersion was set to 24. Lowering my minSdkVersion to 21 resolved this. This error was getting returned on trying to install apk on the test device. Hope this helps for anyone else setting up device farm on android.

(FIXED) INSTALL_FAILED_INVALID_APK: Failed to extract native , session , Targeting SDK Android Q results in Failed to finalize session : INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2 � android� Teams. Q&A for Work. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information.

User user1159819, from Android Studio. When I'm trying to install APK to device I'm getting. INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2 bitrise build� Q&A for Ubuntu users and developers. Stack Exchange Network. Stack Exchange network consists of 177 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Targeting SDK Android Q results in Failed to finalize session, 11 Targeting SDK Android Q results in Failed to finalize session : INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2 � 8 java.lang. Stack Overflow | The World’s Largest Online Community for Developers

[INSTALL_FAILED_INVALID_APK: Failed to extract native libraries , Targeting SDK Android Q results in Failed to finalize session : INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2. Stack Overflow | The World’s Largest Online Community for Developers

Comments
  • same issue on real device (running Q)
  • same error on my pixel 2
  • Tried it, does not help
  • adb install -t apk-free.apk Performing Streamed Install adb: failed to install apk-free.apk: Failure [INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2]
  • Try adding the following to defaultConfig in app/build.gradle file ` packagingOptions{ doNotStrip "/armeabi/.so" doNotStrip "/armeabi-v7a/.so" doNotStrip "/x86/.so" } `
  • Also make sure any old version of the apk is uninstalled
  • Can you share relevant extracts from your app/build.gradle and Manifest?