Search Unity

shrinker and multidex are not supported yet (gradle)

Discussion in 'Android' started by kiwipxl, Feb 2, 2018.

  1. kiwipxl

    kiwipxl

    Joined:
    Jun 9, 2015
    Posts:
    11
    Hey,

    Been trying to get multidex or proguard working to bypass the 65536 dex count limit for multiple days now. Proguard is very difficult to get working as we have a lot of third party libraries that can break easily. I've tried proguard, but I'd need to invest even a lot more time to get it working properly.

    So multidex is a lot more desirable. Problem is, I'm getting the error "shrinker and multidex are not supported yet". The thing is, I'm using a custom gradle file with minifyEnabled and useProguard both turned off for both debug and release. I've tried many different combinations of this including shrinkResources but it doesn't seem to change anything.

    I've tried enabling proguard or minifyEnabled but I don't want either of them. How can I just enable multidex? What's going on here? What does this error really mean?

    Note that I had to upgrade to Unity 2017.2 because Unity 2017.1 has a Unity bug where Resources.Load is extremely slow for gradle builds. So I'm using gradle 2.1.0 now (but I've tried 2.3.0 before too)

    Thanks
     
    pettiimeister likes this.
  2. chrisrolls55

    chrisrolls55

    Joined:
    Nov 26, 2014
    Posts:
    14
    Had the same problem, solved by exporting and building in Android Studio.

    In Unity's Build Settings choose Gradle as build system and tick Export project.

    Once in Android Studio I had to find the following line and change it from

    dependencies
    {
    classpath 'com.android.tools.build:gradle:2.1.0'
    }

    to

    dependencies
    {
    classpath 'com.android.tools.build:gradle:2.3.3'
    }

    I also turned off ProGuard as it was throwing errors in Android Studio.

    This link has good methods of overcoming this problem, including the export with common problems:
    https://stackoverflow.com/questions/42582850/too-many-field-references-70613-max-is-65536
     
    pettiimeister likes this.
  3. kiwipxl

    kiwipxl

    Joined:
    Jun 9, 2015
    Posts:
    11
    Thanks, that helped me setup Android Studio so I can build with faster iteration (wasn't aware I had to change the gradle version to get it to work).

    It seems the error I'm getting above is due to turning off useProguard. Which doesn't really make sense, since the error is saying it doesn't want useProguard and multiDexEnabled on at the same time right?
    Even more is I'm thinking it might not even be using proguard when I turn on useProguard. It could be that this is a gradle bug, but I'm not sure.

    Slowly progressing from here though... got some random exceptions that I have to try and deal with. Much pain.
     
  4. pettiimeister

    pettiimeister

    Joined:
    Mar 4, 2018
    Posts:
    2
    Thanks a lot for this answer. I was having the same exact problem and I also needed to change the classpath line from gradle:4.0.1 to gradle:2.3.3 because there is no 4.0.1 folder (at least today) in the following directory:

    https://jcenter.bintray.com/com/android/tools/build/gradle/
     
  5. Marat_Gilyazov

    Marat_Gilyazov

    Joined:
    Feb 23, 2016
    Posts:
    5
    I've faced the same "shrinker and multidex are not supported yet (gradle)" after enabling "custom gradle template" and adding "multiDexEnabled true" to it (minification and proguard were disabled).

    I found a solution here: https://appmediation.com/unity-enable-multidex/ - just comment or remove any minifyEnabled and useProguard lines from your Gradle template. Like:
    Code (CSharp):
    1. buildTypes {
    2.           debug {
    3.              //minifyEnabled **MINIFY_DEBUG**
    4.              //useProguard **PROGUARD_DEBUG**
    5.              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD**
    6.               jniDebuggable true
    7.           }
    8.           release {
    9.              //minifyEnabled **MINIFY_RELEASE**
    10.              //useProguard **PROGUARD_RELEASE**
    11.               proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD**
    12.               **SIGNCONFIG**
    13.           }
    14.     }
    Voila - now I'm able to build an APK with multidex enabled just from Unity 2018.1, without need to export to Android Studio.
     
    jaortiz, SkygodGames and oskar-szulc like this.
  6. Riddhesh

    Riddhesh

    Joined:
    Jan 5, 2015
    Posts:
    4
    I had the same problem. When I started using AppOdeal mediation, they recommended us to enable MultiDex to avoid 65k error and get the best performance in the mediation network.

    At first attempt, I was getting the same error.

    But after applying solution of @Marat_Gilyazov it solved my problem and build works fine.

    Comment out minifyEnabled & useProguard lines, and it should work for you.