Search Unity

[Bug] Error: "Unable to initialize the Unity Engine" on Android devices when using code stripping

Discussion in 'Editor & General Support' started by amzin7000, Sep 1, 2016.

  1. amzin7000

    amzin7000

    Joined:
    Nov 16, 2014
    Posts:
    48
    Hello all,

    Whenever I compile my game(after moving to 5.4.0f3) for android using any form of code stripping("micro mscorlib" too), my game will compile fine with one error(pasted below), but won't load on the phone and will instead show a black screen with a white box saying: "Error: Unable to initialize the Unity Engine".

    Searching for "Error: Unable to initialize the Unity Engine" gives no relevant results on google.

    I tested on an android 5.1.1 Galaxy Core Prime, 5.1 Moto X, and 5.1.1 Moto G with the exact same results.

    I tried rebuilding my project, restarting unity, and deleting my resources file to force unity to rebuild and reimport everything.

    Should I post it as a bug, and if it is a bug, has it been fixed in the next major release?

    Thanks in advance


    Compiler error:
    UnityException: Failed assemblies stripper: C:/Program Files/Unity/Editor/Data/Mono/bin\mono.exe "C:\Program Files\Unity\Editor\Data\Tools/UnusedBytecodeStripper.exe" -l none -c link -a "Assembly-CSharp-firstpass.dll" -a "Assembly-CSharp.dll" -out output -x "C:\Program Files\Unity\Editor\Data\Tools\link.xml" -d "Temp/StagingArea/Data/Managed" -x "C:\Users\user\Desktop\secretGameTitle\Assets\Photon Unity Networking\link.xml" -x "tmplink.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Whitelists\AI.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Whitelists\Animation.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Whitelists\Audio.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Whitelists\Core.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Whitelists\IMGUI.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Whitelists\JSONSerialize.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Whitelists\ParticlesLegacy.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Whitelists\ParticleSystem.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Whitelists\Physics.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Whitelists\Physics2D.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Whitelists\Terrain.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Whitelists\TerrainPhysics.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Whitelists\TextRendering.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Whitelists\UI.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Whitelists\UNET.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Whitelists\UnityAds.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Whitelists\UnityAnalytics.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Whitelists\UnityConnect.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Whitelists\UnityWebRequest.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Whitelists\VR.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Whitelists\Web.xml" current dir : Temp/StagingArea/Data/Managed
    result file exists: False. Timed out: False
    stdout:
    stderr:
    Unhandled Exception: Mono.Linker.ResolutionException: Can not resolve reference: System.Configuration.IConfigurationSectionHandler
    at Mono.Linker.Steps.MarkStep.MarkType (Mono.Cecil.TypeReference reference, System.Object markedby) [0x00000] in <filename unknown>:0
    at Mono.Linker.Steps.MarkStep.MarkField (Mono.Cecil.FieldReference reference, System.Object markedby) [0x00000] in <filename unknown>:0
    at Mono.Linker.Steps.MarkStep.MarkFields (Mono.Cecil.TypeDefinition type) [0x00000] in <filename unknown>:0
    at UnusedBytecodeStripper.VerboseMarkStep.ApplyPreserveInfo (Mono.Cecil.TypeDefinition type) [0x00000] in <filename unknown>:0
    at Mono.Linker.Steps.MarkStep.MarkType (Mono.Cecil.TypeReference reference, System.Object markedby) [0x00000] in <filename unknown>:0
    at Mono.Linker.Steps.MarkStep.MarkType (Mono.Cecil.TypeReference reference, System.Object markedby) [0x00000] in <filename unknown>:0
    at Mono.Linker.Steps.MarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x00000] in <filename unknown>:0
    at Mono.Linker.Steps.MarkStep.InitializeType (Mono.Cecil.TypeDefinition type) [0x00000] in <filename unknown>:0
    at UnusedBytecodeStripper.VerboseMarkStep.InitializeType (Mono.Cecil.TypeDefinition type) [0x00000] in <filename unknown>:0
    at Mono.Linker.Steps.MarkStep.InitializeAssembly (Mono.Cecil.AssemblyDefinition assembly) [0x00000] in <filename unknown>:0
    at Mono.Linker.Steps.MarkStep.Initialize () [0x00000] in <filename unknown>:0
    at Mono.Linker.Steps.MarkStep.Process (Mono.Linker.LinkContext context) [0x00000] in <filename unknown>:0
    at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x00000] in <filename unknown>:0
    at UnusedBytecodeStripper.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0

    UnityEditor.MonoProcessUtility.RunMonoProcess (System.Diagnostics.Process process, System.String name, System.String resultingFile)
    UnityEditor.MonoAssemblyStripping.MonoLink (BuildTarget buildTarget, System.String managedLibrariesDirectory, System.String[] input, System.String[] allAssemblies, UnityEditor.RuntimeClassRegistry usedClasses)
    UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()
     
  2. amzin7000

    amzin7000

    Joined:
    Nov 16, 2014
    Posts:
    48
    Update: The bug only happens when using .NET 2.0 subset.
     
    image28 likes this.
  3. image28

    image28

    Joined:
    Jul 17, 2013
    Posts:
    457
    Having this same issue, trying with Net 2.0 instead of Net 2.0 Subset now...
     
  4. image28

    image28

    Joined:
    Jul 17, 2013
    Posts:
    457
    Worked for me
     
  5. amzin7000

    amzin7000

    Joined:
    Nov 16, 2014
    Posts:
    48
    Ok good. So i'm not the only one experiencing this. I'll try with an empty project and then submit a bug report.

    Update: an empty project does not cause the bug.
     
    Last edited: Sep 4, 2016
  6. themobilecm

    themobilecm

    Joined:
    Sep 13, 2016
    Posts:
    2
    I'm a noob. How do I switch from subset to .NET2.0?
     
  7. amzin7000

    amzin7000

    Joined:
    Nov 16, 2014
    Posts:
    48
    Its in playerSettings.
     
  8. themobilecm

    themobilecm

    Joined:
    Sep 13, 2016
    Posts:
    2
    Thank you! @amzin7000. For some reason I'm still getting the "Error: Unable to initialize the unity engine". I have changed the target SDK on the android manifest to 21; switched the playerSettings to .Net 2.0 (from subset as per your advice).

    I am trying to run the app on a rooted xiaomi mi note with Marshmallow (Android 6.x). Any help would be greatly appreciated. Thanks in advance.
     
  9. papacharis

    papacharis

    Joined:
    Mar 27, 2017
    Posts:
    1
    @themobilecm
    Any solution?
    I am getting the same error + I have the same device as yours
     
    bayusnote2 likes this.
  10. KB73

    KB73

    Joined:
    Feb 7, 2013
    Posts:
    234
    Seeing the same error on our build ( Error: Unable to initialize the unity engine ) - i am testing 2017 beta 5, i tried an empty project and that works ok. Turns out it was Strip Assemblies enabled, disable this and i can get in.
     
  11. mesuttasci

    mesuttasci

    Joined:
    May 7, 2017
    Posts:
    12
    it didnt work for me
     
  12. KB73

    KB73

    Joined:
    Feb 7, 2013
    Posts:
    234
    * It looks like it is plugin related, an empty project, works ok with or without the strip assemblies....still investigating
     
  13. sledgeman

    sledgeman

    Joined:
    Jun 23, 2014
    Posts:
    389
    Does anybody know when this issue will be fixed ? My build size is twice as big as when i switch to .NET 2.0 subset. Before i update to 5.6 there weren´t any such probs.
     
  14. Alimohammadlo

    Alimohammadlo

    Joined:
    Jun 20, 2017
    Posts:
    16
    hello gays i am 3 day age this is error see i can not fixed error please help us for fix this because i am very low time for send project to admin studios please help me
     
  15. livingtech

    livingtech

    Joined:
    Aug 7, 2015
    Posts:
    9
    I'm using 2017.2.0p4, and running into this error in a completely new empty project.

    My device is a Samsung Galaxy S7, running Android 7.0

    I have tried numerous configurations/combinations of configurations and player settings, and all of them give the error.
     
  16. livingtech

    livingtech

    Joined:
    Aug 7, 2015
    Posts:
    9
    I finally tried switching to 2017.3.0f3, and a new project works. *whew*
     
  17. dashbehzad

    dashbehzad

    Joined:
    Jul 24, 2018
    Posts:
    2
    any solution ?
     
  18. garjak

    garjak

    Joined:
    Jun 22, 2017
    Posts:
    1
    I had a few Unity versions installed, notably 2018.3.10 and was using UnitySetup-Android-Support-for-Editor-2018.3.10f1 , but mainly using Unity 2018.3.1f1 on the project with this error.
    Must be some conflict as what solved it for me was to uninstall Unity v10 along with the corresponding Support for Editor 2018.3.10, then reinstall UnitySetup-Android-Support-for-Editor-2018.3.1f1 and run corresponding Unity editor 2018.3.1f1 and now builds run fine. few!
     
  19. DKShekhawat

    DKShekhawat

    Joined:
    Apr 3, 2021
    Posts:
    1
    I am also facing the same problem . Unity version 2021 and 2020. Whatever I made , don't work in phone and the error comes
    Error: "Unable to initialize the Unity Engine" . Please help me that how to resolve this issue.
     
  20. starman12345678

    starman12345678

    Joined:
    Apr 7, 2021
    Posts:
    2
    pls i need help to im on samsung galaxy s8
     
  21. alevjen

    alevjen

    Joined:
    Sep 11, 2020
    Posts:
    11
    This is also happening for me in 2020.3.16f1 - on multiple devices and emulated android devices through Android Studio.

    Is there any reliable fix?