Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Build-in class shrinker and multidex are not supported yet error

Discussion in 'Android' started by Elllkin, Apr 24, 2018.

  1. Elllkin

    Elllkin

    Joined:
    Mar 14, 2018
    Posts:
    2
    I am making a game in Unity and i need to use some plugins but according to my research i need to enable multiDex in order to build it. I followed https://stackoverflow.com/questions/42582850/too-many-field-references-70613-max-is-65536 and https://stackoverflow.com/questions...s-shrinker-and-multidex-are-not-supported-yet and other solutions to enable it but i keep getting the error.

    These are the my configuration files:

    Code (build.gradle):
    1. // GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
    2. buildscript {
    3.     repositories {
    4.         jcenter()
    5.     }
    6.  
    7.     dependencies {
    8.         classpath 'com.android.tools.build:gradle:2.3.3'
    9.     }
    10. }
    11.  
    12. allprojects {
    13.    repositories {
    14.       flatDir {
    15.         dirs 'libs'
    16.       }
    17.    }
    18. }
    19.  
    20. apply plugin: 'com.android.application'
    21.  
    22. dependencies {
    23.     compile 'com.android.support:multidex:1.0.1'
    24.  
    25.     compile fileTree(dir: 'libs', include: ['*.jar'])
    26.     compile(name: 'animated-vector-drawable-25.1.0', ext:'aar')
    27.     compile(name: 'appcompat-v7-25.1.0', ext:'aar')
    28.     compile(name: 'arcore_client', ext:'aar')
    29.     compile(name: 'com.android.support.animated-vector-drawable-25.3.1', ext:'aar')
    30.     compile(name: 'com.android.support.appcompat-v7-25.3.1', ext:'aar')
    31.     compile(name: 'com.android.support.cardview-v7-25.3.1', ext:'aar')
    32.     compile(name: 'com.android.support.customtabs-25.3.1', ext:'aar')
    33.     compile(name: 'com.android.support.support-compat-25.3.1', ext:'aar')
    34.     compile(name: 'com.android.support.support-core-ui-25.3.1', ext:'aar')
    35.     compile(name: 'com.android.support.support-core-utils-25.3.1', ext:'aar')
    36.     compile(name: 'com.android.support.support-fragment-25.3.1', ext:'aar')
    37.     compile(name: 'com.android.support.support-media-compat-25.3.1', ext:'aar')
    38.     compile(name: 'com.android.support.support-v4-25.3.1', ext:'aar')
    39.     compile(name: 'com.android.support.support-vector-drawable-25.3.1', ext:'aar')
    40.     compile(name: 'facebook-android-wrapper-7.11.1', ext:'aar')
    41.     compile(name: 'facebook-applinks', ext:'aar')
    42.     compile(name: 'google_ar_required', ext:'aar')
    43.     compile(name: 'mapbox-android-telemetry-2-1-0', ext:'aar')
    44.     compile(name: 'support-compat-25.1.0', ext:'aar')
    45.     compile(name: 'support-core-ui-25.1.0', ext:'aar')
    46.     compile(name: 'support-core-utils-25.1.0', ext:'aar')
    47.     compile(name: 'support-media-compat-25.1.0', ext:'aar')
    48.     compile(name: 'support-v4-25.1.0', ext:'aar')
    49.     compile(name: 'support-vector-drawable-25.1.0', ext:'aar')
    50.     compile(name: 'unityandroidpermissions', ext:'aar')
    51.     compile(name: 'unitygar', ext:'aar')
    52. }
    53.  
    54. android {
    55.     compileSdkVersion 27
    56.     buildToolsVersion '27.0.3'
    57.  
    58.     defaultConfig {
    59.         targetSdkVersion 27
    60.         applicationId 'com.company.multidexissue'
    61.         multiDexEnabled true
    62.     }
    63.  
    64.     lintOptions {
    65.         abortOnError false
    66.     }
    67.  
    68.     aaptOptions {
    69.         noCompress '.unity3d', '.ress', '.resource', '.obb'
    70.     }
    71.  
    72.  
    73.     buildTypes {
    74.           debug {
    75.              minifyEnabled false
    76.              useProguard false
    77.              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
    78.               jniDebuggable true
    79.           }
    80.           release {
    81.              minifyEnabled false
    82.              useProguard false
    83.               proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
    84.               signingConfig signingConfigs.debug
    85.           }
    86.     }
    87.  
    88.     dexOptions {
    89.         javaMaxHeapSize "4g"
    90.     }
    91.  
    92. }
    93.  
    Code (AndroidManifest.xml):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.company.multidexissue" xmlns:tools="http://schemas.android.com/tools" android:versionName="1.0" android:versionCode="1" android:installLocation="preferExternal">
    3.   <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
    4.   <application  android:name="android.support.multidex.MultiDexApplication" android:theme="@style/UnityThemeSelector" android:icon="@drawable/app_icon" android:label="@string/app_name" android:isGame="true" android:banner="@drawable/app_banner">
    5.     <activity android:label="@string/app_name" android:screenOrientation="fullSensor" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density" android:name="com.company.multidexissue.UnityPlayerActivity">
    6.       <intent-filter>
    7.         <action android:name="android.intent.action.MAIN" />
    8.         <category android:name="android.intent.category.LAUNCHER" />
    9.         <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
    10.       </intent-filter>
    11.       <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    12.     </activity>
    13.     <activity android:name="com.facebook.unity.FBUnityLoginActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
    14.     <activity android:name="com.facebook.unity.FBUnityDialogsActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
    15.     <activity android:name="com.facebook.unity.FBUnityAppLinkActivity" android:exported="true" />
    16.     <activity android:name="com.facebook.unity.FBUnityDeepLinkingActivity" android:exported="true" />
    17.     <activity android:name="com.facebook.unity.FBUnityGameRequestActivity" />
    18.     <activity android:name="com.facebook.unity.FBUnityCreateGameGroupActivity" />
    19.     <activity android:name="com.facebook.unity.FBUnityJoinGameGroupActivity" />
    20.     <activity android:name="com.facebook.unity.AppInviteDialogActivity" />
    21.     <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="fb225170764728228" />
    22.     <provider android:name="com.facebook.FacebookContentProvider" android:authorities="com.facebook.app.FacebookContentProvider225170764728228" android:exported="true" />
    23.     <meta-data android:name="unity.build-id" android:value="f4999983-4b6b-4aed-b1b8-11a54a7d7644" />
    24.     <meta-data android:name="unity.splash-mode" android:value="0" />
    25.     <meta-data android:name="unity.splash-enable" android:value="True" />
    26.     <meta-data android:name="android.max_aspect" android:value="2.1" />
    27.   </application>
    28.   <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="27" />
    29.   <uses-feature android:glEsVersion="0x00020000" />
    30.   <uses-permission android:name="android.permission.INTERNET" />
    31.   <uses-permission android:name="android.permission.VIBRATE" />
    32.   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    33.   <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    34.   <uses-feature android:name="android.hardware.location.gps" android:required="false" />
    35.   <uses-feature android:name="android.hardware.location" android:required="false" />
    36.   <uses-permission android:name="android.permission.CAMERA" />
    37.   <uses-feature android:name="android.hardware.camera" android:required="false" />
    38.   <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
    39.   <uses-feature android:name="android.hardware.camera.front" android:required="false" />
    40.   <uses-feature android:name="android.hardware.sensor.accelerometer" android:required="false" />
    41.   <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
    42.   <uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false" />
    43.   <uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false" />
    44. </manifest>

    Sorry for the long code
     
  2. BenoitFreslon

    BenoitFreslon

    Joined:
    Jan 16, 2013
    Posts:
    163
    Hello @Elllkin did you solve your problem?
     
  3. Elllkin

    Elllkin

    Joined:
    Mar 14, 2018
    Posts:
    2
    @badben , Unfortunality no :(
     
  4. nabsteri10ri

    nabsteri10ri

    Joined:
    Oct 1, 2016
    Posts:
    3
    The solution for me was to add
    shrinkResources false to both the debug and release buildTypes:

    buildTypes {
    debug {
    //minifyEnabled false
    shrinkResources false
    //useProguard false
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt','proguard-user.txt'
    jniDebuggable true
    }
    release {
    minifyEnabled false
    shrinkResources false
    //useProguard true
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt','proguard-user.txt'
    signingConfig signingConfigs.release
    }
    }

    Also in the AndroidManifest.xml add
    android:name="android.support.multidex.MultiDexApplication" to the application