I get: Error: execution completed for task ': app: transformClassesWithDexForDebug'. when creating the Google maps application

I followed the instructions at this link: https://developers.google.com/maps/documentation/android-api/start to make a simple Android application with the Google Maps API, but I always get this error below when I run application on your phone:

Error: execution completed for task ': app: transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method identifier not in [0, 0xffff]: 65536

0
source share
2 answers

clear and see another error if yes

1.go to your build.gradle file. add multiDexEnabled true

  defaultConfig { multiDexEnabled true } 

2. in your dependencies add compile 'com.android.support:multidex:1.0.1'

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

3. Insert your application tag in menifest add android:name="android.support.multidex.MultiDexApplication"

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

4. Use this override method at startup.

  @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); } 
+1
source

Check if you are dependent on all Google Play services, not just the map component. From the documentation

If the number of method references in the application exceeds the limit of 65K, your application may not compile. You can fix this problem when compiling your application by specifying only the Google Play services APIs that use your application, and not all of them. For information on how to do this, see the "Custom Compilation API" section in your executable file.

For example (using the latest version of the Services Services), change this to build.gradle

 dependencies { compile 'com.google.android.gms:play-services:10.0.1' } 

For this

 dependencies { compile 'com.google.android.gms:play-services-maps:10.0.1' } 

If you add other Service Services modules, you will need to add them to your build.gradle individually.

+1
source

Source: https://habr.com/ru/post/1013350/


All Articles