I recently updated Unity to 2019.1.x from 2018.x, and now I can no longer deploy to Android 8 with an IL2CPP release build. The app crash immediately upon launch with errors like this:
I cannot recall that I had this problem when using Unity 2018.x. The app seems to work OK on my galaxy Tab S5e (Android 9) but there are problems on my Galaxy Tab S3 (Android 8), like this:
Mono build (Release and Debug) works.
IL2CPP Debug build works.
IL2CPP Release build crash on launch with the error mentioned above.
I have tried with variolous stripping levels and with/without ARM64 support; everything fails when a release build is deployed to my Android 8 device, everything works when deployed to my Android 9 device. I havenât tried with any other devices.
Sounds like another missed case then. Could you tell the exact phone model and Android version on it?
Hopefully we will be able to reproduce and fix it then.
Hey GuruGurra, do you get this crash with newly created empty project? If not, could you submit a bug report with project where it reproduces and write number of the bug report here?
OK, a theory (that might be rather serious, if Iâm right)âŚ
I stripped my app to bare minimum, removed all scenes but one, removed most of the script code and only logged when/if my app started. It doesnât start. SoâŚthe problem isnât my code.
I believe that the problem is the automatic backup/restore of app data that Android is doing, and that this (restore) breaks IL2CPP in some way (remember: the problem occurs only with IL2CPP). Consider this:
I open the App settings and clear cache and app data.
I verify that the app folder is empty
I uninstall the app.
I verify that the app folder is deleted.
I install the app.
The app crashes upon start.
I check the app folder - it contains a number of files. Files that are not created by the current version of the app since all code is removed.
Obviously Android has restored the app folder data from a backup. Among the restored data is an IL2CPP folder with a content that differs from that of a fresh installed app (see below).
I configure Android to not restore app data when an app is reinstalled.
I uninstall the app.
I install the app.
I start the app.
The app starts without any problems.
I check the app folder - it contains only an IL2CPP folder (since the current version of my code doesnât create any files).
My guess is that the Android auto-restore pushes an IL2CPP folder into the app folder - an IL2CPP folder with a content that is not compatible with the new package. I donât really know what the folder is used for, but a file compare tells me there are differences between the content that is installed with the apk file and the content that is restored by Android.
This also explain the weird behavior that the app works after a second install since the auto restore isnât active at the second installation; allowing the ârealâ IL2CPP folder to be installed by the apk package.
If this theory is correct I guess that more developers than me will be affected by this problem.
There is another possible reason, it can be determine via hardcore way:
Go to Unity Editor app and in itâs package locate this file: il2cpp/libil2cpp/os/Android/Image.cpp
It contains a function FindManagedCodeSectionInElfBinary. Modify it by adding some android native logging: Logging | Android NDK | Android Developers
It could be that the crash is caused by an attempt to read a particular file mapped to memory and the intermittence of the crash comes from the order of files in the list being processed.
It looks like this might be the issue.
I had problems with my app crashing on launch (only Release builds downloaded from Google Play crashes). When I disable automatic restore in my phone settings, the app launches. This is pretty bad if it really is the issue.
Weâre facing the exact same issue and to be honest Itâs been driving us nuts for the last week.
Hope itâs solved soon cause itâs stopping our whole update roadmap due to being forced to use the IL2CPP in order to meet the google 64 bit demandsâŚ
At least we know whatâs going on and stop trying crazy thigs here and there.
Thank you GuruGurra for the tip, you have saved some serious amount of sannity today!!
For me it has only happened sometimes with a version downloaded from Google Play (internal test in my case), and only when auto backup has been active.
It happened pretty consistently with application built with Unity 2019.1.3, and then when I built with 2019.1.4 it seemed like it went away, but when using 2019.1.4, there auto backup did not seem to work eitherâŚ
I have never had an application stacktrace, only SEGV_MAPERR and SEGV_ACCERR.
I have disabled auto backup and hope that âfixesâ the problem.
The only library that does something special that I can think of is the Fullserializer json library (https://github.com/jacobdufault/fullserializer)
Donât know if it could be some combination of what it does with AOT and auto backup that causes problems. This is pure speculation though, and I donât know what I am talking about.
For us Itâs been happening consistently with multiple test devices using the Unity version 2019.1.0f2.
As far as our test goes,It doesnât matter witch target architecure.
If you have installed the app using the IL2CPP with a previous version of Unity it crashes upon start every single time, before even the splash screen shows up, unless you disable the automatic backup/restore from the device.
You probably know this, but if you do not need auto backups you can disable it for the app by copying \Editor\Data\PlaybackEngines\AndroidPlayer\Apk\AndroidManifest.xml to \Assets\Plugins\Android\
And adding this to the application tag:
android:allowBackup=âfalseâ tools:replace=âandroid:allowBackupâ
Iâm having the same issue: when I install on my device the first time, it doesnât work, after I clear data, it works. Thatâs weird! Any news about the fix?
I am having a similar but different issue. I am using Jenkins to automate my builds but somehow, the resulting binaries seem to be those of previous builds. After extensive research, I found that there were 2 main problems. One of which was the Android backup as mentioned above that keeps restoring binaries from previous app versions.
The other, being the gradle workflow apparently caches compiled binaries if the source was not extensively modified. My project is utilizing the assembly definition extensively due to code organization and team collaboration. That being said, each rapid build is of course, contain little modifications to each library files.
Is there a way to include a clean cache option into the gradle workflow?
We are having the same issue and @GuruGurra 's theory matches all of our suspicions and tests.
Adding allowBackup=false seems to have solved the issue for now, but this means we are removing the backup feature, which is very nice to have
Hi @Ara27 , could you give me more details how are you installing the apk? do you have a reproduction case? I am trying to reproduce it but no luck yet.