任务 ':packageAllDebugClassesForMultiDex' 执行失败
Execution failed for task ':packageAllDebugClassesForMultiDex'
我正在尝试对一个项目使用新的 android multidex 支持。我对这个例外有一些疑问:
错误:任务“:shineV3:packageAllDebugClassesForMultiDex”执行失败。
java.util.zip.ZipException: duplicate entry: com/google/android/gms/analytics/internal/Command.class
关于这个问题。我使用 2 个不同的 jar 包作为依赖项,一些 class 将在 classes.dex 中重复,因为两个 jar 都包含它们。任何的想法?
提前致谢
对于那些参与其中的人,我明白了为什么会这样。对我来说,我正在编译 Google Analytics V2 jar 以及完整的播放服务。 Google 允许您分解您的应用程序真正需要的播放服务并编译这些单独的项目。查看它们 here。我排除了现在在 V4 上的 Google Play Analytics,它有效
将此添加到您的 grdale 编译 "com.google.android.gms:play-services:7.5.+" 意味着添加所有播放服务,包括分析、地图、vcm .. 等。您可以添加
如指南所述:
In versions of Google Play services prior to 6.5, you had to compile
the entire package of APIs into your app. In some cases, doing so made
it more difficult to keep the number of methods in your app (including
framework APIs, library methods, and your own code) under the 65,536
limit.
From version 6.5, you can instead selectively compile Google Play
service APIs into your app. For example, to include only the Google
Fit and Android Wear APIs, replace the following line in your
build.gradle file:
compile 'com.google.android.gms:play-services:7.5.0' with these lines:
compile 'com.google.android.gms:play-services-fitness:7.5.0' compile
'com.google.android.gms:play-services-wearable:7.5.0'
如果您要在应用中集成 Google Analytics V2
和 Google play services
,则需要在 gradle 文件中执行以下操作:
dependencies {
compile 'com.google.android.gms:play-services:4.0.30'
compile files('libs/libGoogleAnalyticsServices.jar')
}
它对我有用。希望它也适用于其他人。 :)
我正在尝试对一个项目使用新的 android multidex 支持。我对这个例外有一些疑问:
错误:任务“:shineV3:packageAllDebugClassesForMultiDex”执行失败。
java.util.zip.ZipException: duplicate entry: com/google/android/gms/analytics/internal/Command.class
关于这个问题。我使用 2 个不同的 jar 包作为依赖项,一些 class 将在 classes.dex 中重复,因为两个 jar 都包含它们。任何的想法? 提前致谢
对于那些参与其中的人,我明白了为什么会这样。对我来说,我正在编译 Google Analytics V2 jar 以及完整的播放服务。 Google 允许您分解您的应用程序真正需要的播放服务并编译这些单独的项目。查看它们 here。我排除了现在在 V4 上的 Google Play Analytics,它有效
将此添加到您的 grdale 编译 "com.google.android.gms:play-services:7.5.+" 意味着添加所有播放服务,包括分析、地图、vcm .. 等。您可以添加
如指南所述:
In versions of Google Play services prior to 6.5, you had to compile the entire package of APIs into your app. In some cases, doing so made it more difficult to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.
From version 6.5, you can instead selectively compile Google Play service APIs into your app. For example, to include only the Google Fit and Android Wear APIs, replace the following line in your build.gradle file:
compile 'com.google.android.gms:play-services:7.5.0' with these lines:
compile 'com.google.android.gms:play-services-fitness:7.5.0' compile 'com.google.android.gms:play-services-wearable:7.5.0'
如果您要在应用中集成 Google Analytics V2
和 Google play services
,则需要在 gradle 文件中执行以下操作:
dependencies {
compile 'com.google.android.gms:play-services:4.0.30'
compile files('libs/libGoogleAnalyticsServices.jar')
}
它对我有用。希望它也适用于其他人。 :)