Java I get:错误:任务';的执行失败:应用程序:transformClassesWithDexForDebug';。在制作谷歌地图应用程序时
我按照此链接中的说明操作:使用Google Maps API制作一个简单的android应用程序,但当我在手机上运行该应用程序时,总会出现以下错误: 错误:任务“:app:transformClassesWithDexForDebug”的执行失败。 com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:com.android.dex.DexIndexOverflowException:方法ID不在[0,0xffff]:65536Java I get:错误:任务';的执行失败:应用程序:transformClassesWithDexForDebug';。在制作谷歌地图应用程序时,java,android,google-maps,google-maps-android-api-2,Java,Android,Google Maps,Google Maps Android Api 2,我按照此链接中的说明操作:使用Google Maps API制作一个简单的android应用程序,但当我在手机上运行该应用程序时,总会出现以下错误: 错误:任务“:app:transformClassesWithDexForDebug”的执行失败。 com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:java.util.concurrent.Execu
清理并查看是否仍然存在错误如果是 1.转到您的
build.gradle
文件。
添加multiDexEnabled true
defaultConfig {
multiDexEnabled true
}
2.在依赖项中添加compile'com.android.support:multidex:1.0.1'
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
3.在menifest的应用程序标签中添加android:name=“android.support.multidex.MultiDexApplication”
清理并查看是否仍然存在错误如果是 1.转到您的
build.gradle
文件。
添加multiDexEnabled true
defaultConfig {
multiDexEnabled true
}
2.在依赖项中添加compile'com.android.support:multidex:1.0.1'
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
3.在menifest的应用程序标签中添加android:name=“android.support.multidex.MultiDexApplication”
检查您是否依赖于整个Google Play服务,而不仅仅依赖于地图组件。从 如果应用程序中的方法引用数超过65K限制,则应用程序可能无法编译。在编译应用程序时,您可以通过仅指定应用程序使用的特定Google Play services API(而不是所有API)来缓解此问题。有关如何执行此操作的信息,请参阅选择性地将API编译到可执行文件中 例如(使用最新的Play Services版本),在您的
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
。检查您是否依赖于整个Google播放服务,而不仅仅依赖于地图组件。从
如果应用程序中的方法引用数超过65K限制,则应用程序可能无法编译。在编译应用程序时,您可以通过仅指定应用程序使用的特定Google Play services API(而不是所有API)来缓解此问题。有关如何执行此操作的信息,请参阅选择性地将API编译到可执行文件中
例如(使用最新的Play Services版本),在您的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'
}
如果您添加其他Play Services模块,则需要将它们单独添加到您的
build.gradle
。您可能希望在应用程序类中扩展MultiDexApplication,或在清单中将其设置为应用程序名称您可能希望在应用程序类中扩展MultiDexApplication,或在清单中将其设置为应用程序名称我认为您不需要在启动活动中覆盖attachBaseContext。该部分已经由Multidex应用程序完成。根据文档,如果重写应用程序类,则只应重写attachBaseContext:我认为在启动活动中不需要重写attachBaseContext。该部分已经由Multidex应用程序完成。根据文档,如果重写应用程序类,则仅应重写attachBaseContext: