2016-12-04 49 views
0

当我跟着这个链接的说明:https://developers.google.com/maps/documentation/android-api/start,以与谷歌地图API一个简单的Android应用程序,但我总是在我的手机上运行的应用程序下面这个错误:我得到:错误:任务':app:transformClassesWithDexForDebug'的执行失败。让谷歌地图应用

Error:Execution failed 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 ID not in [0, 0xffff]: 65536

+1

您可能想要在应用程序类中扩展MultiDexApplication,或将其设置为清单中的应用程序名称 – Eenvincible

回答

1

干净并看到仍然错误是否有,如果是的话,

1.go到您的build.gradle文件。 添加multiDexEnabled true

defaultConfig { 
    multiDexEnabled true 
} 

2.in你的依赖增加compile 'com.android.support:multidex:1.0.1'

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

3.inside在menifest您的应用程序标记添加android:name="android.support.multidex.MultiDexApplication"

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

4.使用您的发射这种重写方法活动

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

我不认为您需要在启动活动中重写attachBaseContext。该部分已由MultiDexApplication完成。根据文档,如果您覆盖Application类,则应该只覆盖attachBaseContext: https://developer.android.com/studio/build/multidex.html –

1

检查您是依赖于整个Google Play服务,而不是仅依赖于地图组件。从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.

例如(使用上次播放服务的版本),你build.gradle

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

对此

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

如果添加其他播放服务模块,您将改变这种需要单独将它们添加到您的build.gradle

相关问题