Xamarin-android: INSTALL_FAILED_INVALID_APK: Package couldn't be installed base.apk code is missing.

Created on 22 Mar 2018  路  13Comments  路  Source: xamarin/xamarin-android

Steps to Reproduce

  1. Go to android project properties.
  2. Select Android Options.
  3. Set Linking SDK assemblies.
  4. Run on android.

Version Information

Android Target Platform 8.1
Minimum OS Version 4.4
Build Tool 27.0.3
Platform Tools 27.0.1
SDK Tools 25.2.5
Xamarin 4.9.0.749

Log File

Output-Build.txt

Most helpful comment

$ ./gradlew clean did the trick for me

I think the build state got in broken state while I stopped a build process midway through

All 13 comments

I'm hitting this too now (VS2019)

I have the similar issue with Visual Studio 2019 16.4.2. It could be reproduced without performing step 2 and 3.

I also experience this since last update to newest stable in VS for Mac
with or without Linking SDK assemblies. Reinstall/Repair Android SDK
didn't help either.

Could workaround it by downgrading to
Xamarin.Android 10.1
https://aka.ms/xamarin-android-commercial-d16-4-macos
I could keep Mono 6.8.0.123
in case you need to downgrade to Mono 6.6.0
https://download.mono-project.com/archive/6.6.0/macos-10-universal/MonoFramework-MDK-6.6.0.macos10.xamarin.universal.pkg

I have the same issue after installing the newest VS for Mac. I am not able to resolve it for the moment.

I'm having this issue aswel with the newest version for Mac.

same here.

I was seeing the same issue after upgrading to the latest VS for Mac.

For us, the solution was to go to Options on the Android project, then on the Android Build tab on the left, unselect Enable Multi-Dex and select d8 as our Dex Compiler.

We weren't targeting below API 21, and d8 appears to be the default compiler in Android Studio since 3.1, so I didn't see any downside altering these settings.

Hope that helps someone else. I am curious as to why the latest version caused this though.

EDIT 1: I believe this change could have had something to do with it: https://docs.microsoft.com/en-us/xamarin/android/release-notes/10/10.2#d8-enabled-by-default-for-all-projects

But I'm still not sure the root cause.

EDIT 2: We updated this setting on our Adhoc and Release builds as well, and needed to enable R8 as the code shrinker for those configurations in order to disable multi-dexing. This conversation was helpful for getting passed an R8 error we saw: https://github.com/xamarin/xamarin-android/issues/3444

For anyone seeing this after the update to the new versions from this month, it sounds like a new different issue has appeared compared to the original problem reported back in 2018. If anyone is still seeing this issue on the latest version after a clean rebuild when using any combination of settings for Enable Multi-Dex, Dex Compiler, and Code Shrinker and could collect the diagnostic build output for the build that's giving the bad behavior and attach it on a new issue so that the team can take a look, that would be perfect. Thanks in advance!

Disabling Multi-Dex and selecting d8 as the Dex Compiler fixed the error for me too

The recent appearance of this issue can now be tracked on https://github.com/xamarin/xamarin-android/issues/4478. Thanks vravindranath for submitting that! If anyone can collect their diagnostic build output and attach it on https://github.com/xamarin/xamarin-android/issues/4478 so the team can take a look, that would be perfect. Thanks!

thanks @maxveldink your solution works for me.

I was seeing the same issue after upgrading to the latest VS for Mac.

For us, the solution was to go to Options on the Android project, then on the Android Build tab on the left, unselect Enable Multi-Dex and select d8 as our Dex Compiler.

We weren't targeting below API 21, and d8 appears to be the default compiler in Android Studio since 3.1, so I didn't see any downside altering these settings.

Hope that helps someone else. I am curious as to why the latest version caused this though.

EDIT 1: I believe this change could have had something to do with it: https://docs.microsoft.com/en-us/xamarin/android/release-notes/10/10.2#d8-enabled-by-default-for-all-projects

But I'm still not sure the root cause.

EDIT 2: We updated this setting on our Adhoc and Release builds as well, and needed to enable R8 as the code shrinker for those configurations in order to disable multi-dexing. This conversation was helpful for getting passed an R8 error we saw: #3444

Don't know what exactly causes the issue.
A had several schemes, all could be build and install all of them and once, one didn't want (after what actions - don't know). In all unknown situations I execute:
npm run mac-reinstall
where in package.json in scripts section:
"mac-reinstall": "rm -rf -v package-lock.json ios/build ios/Podfile.lock android/.gradle android/build android/app/build node_modules && npm i && cd ios/ && rm -rf Pods/ && pod install && cd ../"
You can try to leave only Android's part from the script.

$ ./gradlew clean did the trick for me

I think the build state got in broken state while I stopped a build process midway through

Was this page helpful?
0 / 5 - 0 ratings