google-analytics-plugin-for-unity: Conflict with play-games-plugin-for-unity

The google analytics plugin appears to conflict with the google play games plugin.

With both plugins installed in a project, these two jar files:

  • Assets\Plugins\Android\libGoogleAnalyticsServices.jar
  • Assets\Plugins\Android\google-play-services_lib\libs\google-play-services.jar

both contain the class file com/google/android/gms/analytics/internal/Command.

When attempting to build for Android, the following error is produced:

CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.
C:\Program Files\Java\jdk1.7.0_75\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="/path/to/android/sdk\tools" -Dfile.encoding=UTF8 -jar "C:/Program Files/Unity/Editor/Data/BuildTargetTools/AndroidPlayer\sdktools.jar" -

stderr[

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/analytics/internal/Command;
    at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
    at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
    at com.android.dx.command.dexer.Main.processClass(Main.java:732)
    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
    at com.android.dx.command.dexer.Main.access$300(Main.java:83)
    at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
    at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
    at com.android.dx.command.dexer.Main.processOne(Main.java:632)
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
    at com.android.dx.command.dexer.Main.run(Main.java:246)
    at com.android.dx.command.dexer.Main.main(Main.java:215)
    at com.android.dx.command.Main.main(Main.java:106)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at SDKMain.main(SDKMain.java:129)
1 error; aborting
]

The google-play-services.jar is just the official package sourced directly from the android SDK, while libGoogleAnalyticsServices.jar comes pre-compiled in this git repos, so I figure that this is a problem to be dealt with by this project, rather than by play games services.

About this issue

  • Original URL
  • State: open
  • Created 9 years ago
  • Comments: 43 (3 by maintainers)

Most upvoted comments

This is great, one year later and google play services and analytics still have compatibility issues…

My configuration is: Unity 5.1.2 play-games-plugin-for-unity 0.9.27 google-analytics-plugin-for-unity v4 latest SDK; Google Play services 28 (actually, plugin reports 8.1+)

Installation sequence was: google-analytics then play-games When setup google-analytics-plugin-for-unity on Unity (Menu “Google Analytics-> Setup”. it makes a copy google_play_services_lib into Assets\Pluins\Android directory at this moment Google Analytics works fine. After installation of play-games plug 0.9.27 google_play_services_lib directory disapear. It caused by play-games plug. It found and imported dependences, and clean up Assets\Pluins\Android dictionary removed a “big” library google_play_services_lib. I assume, if to add depencency in google play services for Google Analytics. Google Play Services imports nessesary .aar file. and “big” library is not required any more. Fortunatly, my guess is working. Both GPGS and GA work perfect.

FIX: Locate file <Your Project>\Asstes\GooglePlayGames\Editor\BackgroundResolution.cs Find selfdescriptive method and add C# lines

    private static void AddDependencies()
    {
     ....
     svcSupport.DependOn("com.google.android.gms", 
     "play-services-analytics",      PluginVersion.PlayServicesVersionConstraint); 
    }

after that play-games-plugin-for-unity imports play-services-analytics-8.3.0.aar into Assets\Plugins\Android as well as other nessesary *.aar files

For temporary fix, using r23 of Google Play Services fixed it for me. Like baldwin said. Download link: http://dl.google.com/android/repository/google_play_services_7095000_r23.zip