I get: Error:Execution failed for task ':app:transformClassesWithDexForDebug'. when making Google maps App

后端 未结 2 686
甜味超标
甜味超标 2020-12-20 09:55

I followed the instructions in this link: https://developers.google.com/maps/documentation/android-api/start to make a simple android app with Google Maps API but I always g

相关标签:
2条回答
  • 2020-12-20 10:05

    Check whether you are depending on the whole Google Play Services instead of just depending on the maps component. From the documentation

    If the number of method references in your app exceeds the 65K limit, your app may fail to compile. You may be able to mitigate this problem when compiling your app by specifying only the specific Google Play services APIs your app uses, instead of all of them. For information on how to do this, see Selectively compiling APIs into your executable.

    For example (using the last Play Services version), change this in your build.gradle

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

    To this

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

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

    0 讨论(0)
  • 2020-12-20 10:17

    clean and see still error is there 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.inside your application tag in menifest add android:name="android.support.multidex.MultiDexApplication"

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

    4.use this override method on your launching activity

     @Override
        protected void attachBaseContext(Context base) {
            super.attachBaseContext(base);
            MultiDex.install(this);
        }
    
    0 讨论(0)
提交回复
热议问题