Reducing Total Method Count
Streamline your Android build by using lighter dependencies and enabling multidex support to stay within the method count limit.
Read time 1 minuteLast updated 3 hours ago
Remove Entire GPS library and only use play-services-basement
Android Studio Remote Dependency Library Option
If using Android Studio with remote dependency libraries then use the following in the build.gradledependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.google.android.gms:play-services-basement:8.4.0' }
Android Studio Jar file Option
If you want to remove GPS from an existing project and just use the jar then here are the steps required. Removing GPS from an existing project to just include google-play-services-basement.jar. For example the out of the box Tapjoy EasyApp sample includes the entire GPS library. Listed below are the steps showing how to remove this and just use the required google-play-services-basement.jar. Remove references to GPS in the following locations- Settings.gradle – showing commented out include.
//include ':Libraries:google-play-services_lib' include ':TapjoyEasyApp'
- project.properties.- showing commented out reference to GPS
#android.library.reference.1=../Libraries/google-play-services_lib
- Remove from reference of gps in the build.gradle and add the google-play-services-basement.jar’ jar file.
dependencies { compile fileTree(include: '*.jar', dir: 'libs') // compile project(':Libraries:google-play-services_lib') compile files('libs/google-play-services-basement.jar') }
- AndroidManifest.xml. showing commented out reference to GPS
<application android:icon="@drawable/icon" android:label="@string/app_name" > <!-- <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />-->
Include multi-dex support
Another method is to include an entry into the gradle.build that allows for multidex support. For more information, refer to the Android developer documentation. For more information, refer to the following Unity Discussions posts which discuss workarounds for this issue.- Too many method references when I export android build
- Dex 64k method limit - Get Unity to use gradle build options