google play services追加時のAndroid書き出しエラー


すでに、Google Analytics導入済みのプロジェクトに、Google Play Servicesを追加したらAndroidへ書き出し時に下記のエラーが出た。

CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.
/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java -Xmx2048M -Dcom.android.sdkmanager.toolsdir=”/Users/nao/service/Android/SDK/tools” -Dfile.encoding=UTF8 -jar “/Applications/Unity5.3.2f1/PlaybackEngines/AndroidPlayer/Tools/sdktools.jar” –

stderr[
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/analytics/internal/Command;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/analytics/internal/Command$1;
2 errors; aborting
]
stdout[
processing archive /Users/nao/works/****/git/Temp/StagingArea/android-libraries/google-play-services_lib/libs/./google-play-services.jar…
(略)

どうも、Google Analyticsで使っているライブラリが、Google Play Servicesにも含まれているらしく重複しているためのエラーだった。
libGoogleAnalyticsServices.jarを削除したら直った。

追記)
Google Play Servicesのrevision.23より大きいものを使うとAndroidへ書き出し時にエラーが出てしまった。ここから、revision.23を落とすと解決するようです。
ただ、使っているライブラリによってはreivision.23より大きいものを使わないと行けないので、その場合は
Google Analytics V4を使うと解決できる。

参考)
[WIP] どな帳 | Unity で Google Analytics と AdMob を使う
googleanalytics | google-analytics-plugin-for-unity | Conflict with play-games-plugin-for-unity

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です