2

I am getting build failure after adding Google Play services aar files to my Unity project. Everything was working fine before adding GPS files.

After checking the Unity editor.log, the error says:

Too many method references to fit in one dex file... You may try using multi-dex.

How to resolve this? And enable multidex in Unity project?

Udayan
  • 1,374
  • 1
  • 11
  • 20

1 Answers1

0

How to resolve this?

No, you cant resolve this in Unity. 

And enable multidex in Unity project?

There is workaround to export your project in Android Studio and enable multidex options there.

android {
    defaultConfig {
        ...
        ...
        multiDexEnabled true
    }
    ...
}
dependencies {
  compile 'com.android.support:multidex:1.0.1'
}

Also add this line in your AndroidManifest.xml inside tag.

<application
            android:name="android.support.multidex.MultiDexApplication" >
        ...
</application>

For detail explanation you can visit this link. https://medium.com/@narendrapal39/multidex-unity-android-a5ab48b1704e

Narendra Pal
  • 6,474
  • 13
  • 49
  • 85
  • Thanks for a quick answer. But in export as Google Android project. Which I am unable to open in Studio? I am using Unity 5.4. – Udayan Jul 20 '17 at 09:34
  • Oh, The link i have shared is for Unity 5.6 So in this case. instead of adding whole google play services library, you can add only those .aar which is required. Also If you want whole GPS then first eport your project to Android studio and add GPS there as dependencies. Or you can update your unity verison to 5.6 and export your project directly to Gradle. – Narendra Pal Jul 20 '17 at 09:34