Search Unity

Gradle 3.2.0 crashes app on launch

Discussion in 'Android' started by mboog12, Jul 19, 2019.

  1. mboog12

    mboog12

    Joined:
    Oct 4, 2011
    Posts:
    91
    Hi everyone!

    I am trying to create an app bundle for Google Play using the Build App Bundle check from BuildSettings. The bundle should contain all three architectures: x86, ARMv7 and ARM64.

    I'm using a custom mainTemplate.gradle and for building the App Bundle I have to set "com.android.tools.build:gradle" to version 3.2.0. The problem is that with this gradle version my app crashes right on launch but if I use 3.0.0 the app works fine (but the App Bundle build fails).

    Crash error from Monitor.bat :

    07-19 13:19:48.033: E/AndroidRuntime(31506): java.lang.RuntimeException: Unable to instantiate application android.support.multidex.MultiDexApplication: java.lang.ClassNotFoundException: Didn't find class "android.support.multidex.MultiDexApplication" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/<my app>-CL5QNweziJv6wfVPWDMNsg==/base.apk"],nativeLibraryDirectories=[/data/app/<my app>-CL5QNweziJv6wfVPWDMNsg==/lib/arm64, /data/app/<my app>-CL5QNweziJv6wfVPWDMNsg==/base.apk!/lib/arm64-v8a, /system/lib64]]

    07-19 13:19:48.033: E/AndroidRuntime(31506): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.multidex.MultiDexApplication" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/<my app>-CL5QNweziJv6wfVPWDMNsg==/base.apk"],nativeLibraryDirectories=[/data/app/<my app>-CL5QNweziJv6wfVPWDMNsg==/lib/arm64, /data/app/<my app>-CL5QNweziJv6wfVPWDMNsg==/base.apk!/lib/arm64-v8a, /system/lib64]]
     
  2. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,967
    Do you have any androidx.* files in your Assets/Plugins/Android folder?
     
  3. mboog12

    mboog12

    Joined:
    Oct 4, 2011
    Posts:
    91
    No, I don't, but i have this 2 lines in my mainTemplate :
    it.setProperty("android.useAndroidX", true)
    it.setProperty("android.enableJetifier", true)

    I solved it by changing this line :
    android:name="android.support.multidex.MultiDexApplication"
    in :
    android:name="androidx.multidex.MultiDexApplication"
    in my AndroidManifest.
     
  4. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,967
    Yes, you need to change from android.support to androidx.* if you are using androidX libraries.
    As your mainTemplate is patched with androidX(by Play Services Resolver most likely), the above change should work fine.
     
    Pavenko1 likes this.
  5. skype-bhimanibhavu

    skype-bhimanibhavu

    Joined:
    Sep 15, 2017
    Posts:
    1
    hii,

    I have done this error in my code, I removed android:name="androidx.multidex.MultiDexApplication" in Application. Like this. try this method so you don't need to use custom Gradle.


    <application android:theme="@StyLe/UnityThemeSelector" android:icon="@Mipmap/app_icon" android:label="@String/app_name">
     
  6. imohamadwael

    imohamadwael

    Joined:
    Apr 1, 2020
    Posts:
    1
    Hi @mboog12,
    Has your issue been solved? and if solved, how did you solve it?

    Thanks in advance.
     
  7. Pavenko1

    Pavenko1

    Joined:
    Nov 1, 2018
    Posts:
    1
    it helped me, thanks!
     
    Voxel-Busters likes this.