Android Build crashes on tablet

Hello,

I’ve just finished making my game, and after much fiddling with the preferences, I finally managed to make a successful Android build.

I transferred my APK to a tablet and installed it (I have one device which won’t install it for some reason, and gives no reason, but another that does). However, when I run the game on the tablet that it has installed on, I get either a black screen, or the “Made with Unity” logo, and then the game crashes with the vague message:
“[App Name] has stopped”

I’m unsure why this is happening with my Android build, as my PC/Standalone build works perfectly fine. None of the devices are giving me any kind of explanation as to what is causing the crash, just a simple vague message. A friend even tried it on his phone and wasn’t getting any different results.

These are the build settings I’m using:

  • A keystore is set, and the preferences directory points to the correct folder
  • I have OpenGLE2, Vulkan and OpenGLE3 all in my Graphics APIs (I’ve tried without GLE2, but the result is no different)
  • Minimum API Level is 4.4 (the tablet I’m trying to test it on is on Android 4.4.2)
  • Scripting Backend is IL2CPP
  • API compatibility level is .NET 4x
  • I’ve checked both Target Architectures; ARMv7 and ARM64 (the tablet gave a “library returned null” error message when I only have ARM64 checked. Please let me know if you’d like to see this error message, but bear in mind it isn’t showing any more)

I’m no expert on Android, but I feel the way the build is being made is what’s causing this. I’d be really grateful if someone could help me get to the bottom of this so I can finally get my App to run on an Android device.

On another note, I also get the following yellow warning messages in the console whenever I open my Android player settings:

Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
System.Threading.ThreadHelper:ThreadStart ()

Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
System.Threading.ThreadHelper:ThreadStart ()

Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
System.Threading.ThreadHelper:ThreadStart ()

Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
System.Threading.ThreadHelper:ThreadStart ()

Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
System.Threading.ThreadHelper:ThreadStart ()

If any further information is needed, do let me know. The tablet itself isn’t telling me anything when the app crashes.

Thanks in advance.

Hi, which Unity version do you use?
Are you able to install the app directly to the device from Unity by clicking the build and run button in build settings? If you are, you should be able to use this package https://docs.unity3d.com/Packages/com.unity.mobile.android-logcat@1.2/manual/index.html to see log messages from the device. This way you would get log messages indicating what causes a crash on your device after you run the application.

I’m using 2020.3.15f2 (latest version, I believe).

I just tried what you suggested with the first tablet (the one that never installs). After using “Build and Run”, Unity’s console gives me this:

Installation failed with the following output:
Performing Push Install
D:\My_Documents\UnityProjects\TidalWaveTom\Builds\TWT_Android_Beta\TidalWaveTom.apk: 1 file pushed, 0 skipped. 3.8 MB/s (287765130 bytes in 72.672s)
    pkg: /data/local/tmp/TidalWaveTom.apk

Failure [INSTALL_FAILED_CONTAINER_ERROR]


UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
DeploymentOperationFailedException: Installation failed. See the Console for details.
UnityEditor.Android.AndroidDeploymentTargetsExtension.UploadAPK (UnityEditor.Android.AndroidBuildProperties buildProperties, UnityEditor.Android.AndroidDevice device, UnityEditor.Android.AndroidDeploymentTargetsExtension+LaunchProgressTaskManager taskManager) (at <f5a27061d5634be188a0593af20cb363>:0)
UnityEditor.Android.AndroidDeploymentTargetsExtension+<>c__DisplayClass12_1.<LaunchBuildOnTarget>b__2 () (at <f5a27061d5634be188a0593af20cb363>:0)
UnityEditor.ProgressTaskManager.Run () (at <44c3723143904fb88deebc993c7bb491>:0)
UnityEditor.Android.AndroidDeploymentTargetsExtension.LaunchBuildOnTarget (UnityEditor.DeploymentTargets.IDeploymentTargetsMainThreadContext context, UnityEditor.BuildProperties buildProperties, UnityEditor.DeploymentTargets.DeploymentTargetId targetId, UnityEditor.ProgressHandler progressHandler) (at <f5a27061d5634be188a0593af20cb363>:0)
UnityEditor.DeploymentTargets.DeploymentTargetManager.LaunchBuildOnTarget (UnityEditor.BuildProperties buildProperties, UnityEditor.DeploymentTargets.DeploymentTargetId targetId, UnityEditor.ProgressHandler progressHandler) (at <44c3723143904fb88deebc993c7bb491>:0)
UnityEditor.PostprocessBuildPlayer+<>c__DisplayClass19_1.<LaunchOnTargets>b__1 () (at <44c3723143904fb88deebc993c7bb491>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
UnityException: Could not find any valid targets to launch on for Android
UnityEditor.PostprocessBuildPlayer.LaunchOnTargets (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget buildTarget, UnityEditor.Build.Reporting.BuildReport buildReport, System.Collections.Generic.List`1[T] launchTargets) (at <44c3723143904fb88deebc993c7bb491>:0)
UnityEditor.Android.PostProcessAndroidPlayer.Launch (UnityEditor.BuildTarget target, System.String installPath, UnityEditor.Build.Reporting.BuildReport report) (at <f5a27061d5634be188a0593af20cb363>:0)
UnityEditor.Android.AndroidBuildPostprocessor.LaunchPlayer (UnityEditor.Modules.BuildLaunchPlayerArgs args) (at <f5a27061d5634be188a0593af20cb363>:0)
UnityEditor.PostprocessBuildPlayer.Launch (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget buildTarget, System.String path, System.String productName, UnityEditor.BuildOptions options, UnityEditor.Build.Reporting.BuildReport buildReport) (at <44c3723143904fb88deebc993c7bb491>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
UnityException: Could not find any valid targets to launch on for Android

I’ll try testing it with the other tablet…

EDIT:

Ok, I just did it with the other tablet. I’ve attached three screenshots showing the messages that the Android Logcat displays after the game crashes:



Googling INSTALL_FAILED_CONTAINER_ERROR gets results pointing to the install location setting. Here’s one of the first results that showed up in Google search Failure [INSTALL_FAILED_CONTAINER_ERROR] when trying to install android apk package using adb for platform 4.1 - Stack Overflow you can try changing the install location in the player settings to automatic, which should allow you to install the application on the first tablet as well.

Now the error that you get on the second device seems to be caused by incorrectly stripped code. Do you use minification (a minify section in player settings → publishing settings) and do you have any custom gradle templates in your project (options in player settings → publishing settings as well)? If you do, please update the custom gradle templates based on the default templates that are present in Unity 2020.3.15f2. To do that, you can simply move templates that are overwritten from your project into some other location. Then get back into Unity editor, Unity should recreate those template files based on the default values for that specific Unity editor version. Then you will have to redo your custom changes which you have made previously in the gradle templates that you have moved out.

Hi,

Thanks for the info. I managed to get the game to install on the first tablet via Build and Run.

Regarding minification, I am not using any of its options (all the tickboxes under the minification options: “Use R8”, “Release”, “Debug” and (not sure if this is part of its list or on its own) “Split Application Binary”, are all unchecked). I did see in one of the many searches I’ve done something regarding it, but that had been for an older version so the option it suggested wasn’t present among this version of Unity. Should I check any of the options for my version?

As for the gradle, there’s a long story involving this. During my earlier attempts to making the Android build, I had encountered a lot of “gradle build failed” results when trying to use Unity’s default gradle directory, so I’d been using a manually installed gradle, so maybe it was either the SDK, JDK or NDK that was causing the gradle to fail.

Regardless, I just rechecked the tickbox to use Unity’s recommended gradle directory, but the results are exactly the same as when using the manually installed one. I do not have any custom gradle settings checked; much of my Android player settings are at default except the ones I mentioned in my original post.

Here’s what Android Logcat has to say about it:



Should I try running it with any of the minification options checked?

No, this will not help. The errors that state “Could not find class …” made me think that the issue is caused by stripped out code (that’s why I mentioned minification). I was guessing that maybe those options are checked, so unchecking them was one of the possible things you could try, but since they are already unchecked, this is not the cause of the problem.

Custom Gradle version should not cause this either.

I see that you get “Device driver API match” which I have not seen before. I’ve tried Googling it and the results seem to be related to cyanogenmod custom OS version. Does your tablet use a standard official Android OS version, or is it running a custom OS? If it’s a custom OS, then that might be the reason why it fails. Unity does not support custom unofficial Android OS versions.

If your device runs an official Android OS version, could you try to create a new empty Unity project and then build and run it on your device? If the same issue is reproducible with an empty project - please submit a bug report. If the issue is not reproducible with an empty project, then there is something specifically in your current project which causes this issue. Right now I don’t have other ideas what it could be, so the project would need to be investigated. If you don’t mind providing your project, you could submit a bug report and attach your project. Then someone at Unity will take a look at it to see what causes this issue.

To my knowledge, the tablet I’m using is just on a standard Android package.

Here are the device details:

Anyhow, I just created a new project and tried it. It DOES run fine, though I’ll note that I see a lot of similar messages in the Android Logcat that my main project shows (even though it did run fine on the tablet):



Well, I guess I’ll have to submit my main project somewhere then. Do note that its builds run perfectly fine on PC standalone settings; it’s just the Android version that’s having the issues. Where do I need to submit the bug report?

To report a bug, you can follow the steps here Unity QA: Building quality with passion
After submitting a bug report you can paste the 7 digit bug number in this thread as well. Thank you

Why am I seeing this when reporting a bug?

It’s not something I can delve into, as I’ve waited hours and left my computer on all day with two attempts to report the bug, to the same irritating result, and I really don’t want to do it again. Spent all day waiting for this to upload, only for it to mess up.

Is there an easier way to report the bug with the long wait time and the subsequent crashes? I already submitted a ticket to Unity’s general help, telling them to forward it to the bug report team, along with a shared link to my project.