Unity: Android build errors compilation
Updated: Dec 8, 2021
For all my games, I use:
MoPob mediation to monetize.
Unity Easy Mobile Pro asset to integrate MoPub ADs/mediation and to implement other generic features like app rating etc,.
For reference I am using Unity 2019.4.17f1.
Time to time I see few errors while building for Android. So, in this bog post I am compiling fixes for my future reference and to help for other devs who face these.
Could not find or load main class com.android.manifmerger.Merger
Still not sure what the root cause is for this issue, time to time this reappears and disappears. Things to do to fix this:
Perform this trick Failed to update Android SDK Package List
Get the latest SDK, NDK, and SDK tools from Android Studio that is pointing to Unity Android set up.
Last but not least, get latest assets and import them in my case they are - EasyMobilePro, GameAnalytics, Facebook SDK, GoogleMobileADs
No Java runtime present, requesting install.
After you install Unity for the first time, some times it throws this error.
From https://github.com/firebase/quickstart-unity/issues/849 post: "So first, I know this sounds really odd, but I've seen issues in MacOS in the past that are resolved simply by toggling the "JDK Installed with Unity" button. As in on or off doesn't matter, just that it changes. Try unchecking that and hitting build (without restarting Unity). If that works, that is one bug to start tracking and can help you get unstuck."
I tried toggle & untoggle couple of times and it fixed No Java runtime present, requesting install. issue.
Failed to update Android SDK Package List
step 1 - Disable all checkmarks in preferences and close editor. step 2 - Reopen the editor Enable all checkmarks in preferences after that hit the play button. Now it will start resolving dependencies for android and the problem will be solved
Error: unexpected element <queries> found in <manifest>
To fix this use gradle version that included queries in it, which seems to be above 3.4.3. So use this
Error while merging dex archives: The number of method references in a .dex file cannot exceed 64K.
To fix this enable multidex via launcherTemplate.gradle
Your Android setup is not correct. See Settings in Facebook menu.
Just uncheck recommended Android SDK from Unity preferences and browse Android SDK to the exact same one Unity already using will fix this issue.
You uploaded a debuggable APK or Android App Bundle.
Sometimes when I upload android build that is built with Unity throws this error: You uploaded a debuggable APK or Android App Bundle. For security reasons you need to disable debugging before it can be published in Google Play. Learn more about debuggable APKs and Android App Bundles.
If you are using FacebookSDK which comes with Google Play services, it can be that in injects a Debuggable=true key in the Manifest, for whatever reason.
you can fix it by going to Assets -> Android -> AndroidManifest.xml
In there find 'android:debuggable="true"' and set it to false.
Google Play Console Error: This release is not compliant with the Google Play 64-bit requirement.
To fix this Go to Player Settings -> Other Setting -> Under Configuration
Select IL2CPP for Scripting Background.
Now you will see ARM64 under Target Architecture and check it.
Regenerate build and it shouldn't throw above error anymore.