LoginSignup
5
6

More than 5 years have passed since last update.

Androidエラー: duplicate entry: com/google/android/gms/analytics/internal/Command.class

Last updated at Posted at 2015-05-08

問題

Android Studio でビルドしたところ、下記のエラーによりビルドが失敗しました。

Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/google/android/gms/analytics/internal/Command.class

解決

メッセージが示しているように、Google Analytics のモジュールが重複していることが原因でした。

問題のあるbuild.gradle(抜粋)
dependencies {
    ...
    compile files('libs/libGoogleAnalyticsServices.jar')
    compile 'com.google.android.gms:play-services:7.3.0'
}

play-servicesの中にGoogle Analyticsのモジュールが含まれているため、.jarの方と衝突してしまったようです。
Google Play Services のモジュールは分割してcompileに入れることができるので、下記のように変更しました(Google Cloud Messagingを使いたかったので、このモジュールに絞っています。)

修正後のbuild.gradle(抜粋)
dependencies {
    ...
    compile files('libs/libGoogleAnalyticsServices.jar')
    compile 'com.google.android.gms:play-services-gcm:7.3.0' // play-services を play-services-gcm に変更
}

参考:http://developer.android.com/google/play-services/setup.html#split

※ Analyticsをjarで取り込んでいますが、Maven repositoryにあるので、通常はそちらを使ってください。

5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6