Conflict with play-games-plugin-for-unity #51

matt-spungegames opened this Issue May 4, 2015 · 43 comments


None yet

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"/path/to/android/sdk\tools" -Dfile.encoding=UTF8 -jar "C:/Program Files/Unity/Editor/Data/BuildTargetTools/AndroidPlayer\sdktools.jar" -


java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/analytics/internal/Command;
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at SDKMain.main(
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.



I had the same problem yesterday !

I solved by open the jar with 7zip and delete 2 files under

From memory, it was :

They were in conflict because they already exist in google analytics jar.



Thanks aymericgeffroy,

I used 7zip myself to browse the jar files and find the conflicting jar files. I didn't consider just deleting the classes from one version because they have different CRCs and significantly different file sizes (they clearly have different contents).

Command.class is 2063 bytes in libGoogleAnalyticsServices.jar and only 1483 bytes in google-play-services.jar, and Command$1.class is 1276 vs 1162 bytes. This would seem to indicate that there is more code in the GA version. Perhaps the GPGS version is just a compatible subset of what is in the GA jar file, and we can get away with just removing the GPGS version as a work around. Without the source this is a big assumption to make though. For all we know they could be entirely different implementations. Perhaps the we could get some feedback on this from the project's maintainers.

Regardless of any available work around, this is still a problem that needs to be addressed by the developers.


Indeed, you are right, there is really a problem !
Sorry for the mistake.


Matt, after deleting Comand.class in 'libGoogleAnalyticsServices.jar', i cheked and Google Analytics doesn't work anymore.

Zubius commented May 6, 2015

I've deleted this classes from google-play-services.jar instead
and it works for me. Analytics seems to work now. Not sure it solve problem coz I use only G+ authorization and ad from google libraries.


I have the same issue with Google Play Game Services plugin and Google Analytics plugin. Removing either one of the libraries is not an option. It is very unfortunate that these two plugins are dependant on different versions of other codes.


I was using Google Play Game Services plugin with Google Play service rev.23 in the Android SDK. And it was working fine with the Google Analytics plugin. After I tried to upgrade to rev.24 today, this happens to me, too. I guess you can workaround this issue by downgrading Google Play service to rev.23 for now.

I tired to update the Google Play service since I got this issue:
Though the developer states that it is harmless, but this message is spamming my logcat and it's really annoying.


I have same issue.


Apologies. This appears to be a conflict between the v3 analytics SDK(which the plugin relies on) and r24 of GPS. We'll work on creating a version of the Unity plugin that uses v4 so we can drop the v3 lib.

In the meantime if you can use r23 or earlier to work around it thats probably the best option.

I wouldn't recommend deleting the classes from the GPS jar, but if it works for you.


Could we get a rough estimate (eg. days, weeks or months) of how long it might take until a version of the plugin using v4 of the SDK is released?

That will make it easier for us all to make decisions about whether it's worth rolling back to r23 of Google Play or waiting for Analytics to be updated. Especially for anyone who finds this issue between now until nearer to when you release a v4 version of the plug-in.


Sorry, can't give out a timeline. Which methods are you using?


I’m using the following functions:

Which parts of the API are dependent on the gms Command.class? If we avoid a function or two in the API, can we get away with using a jar file with the conflicting class removed?

bivisss commented May 14, 2015

For temporary fix, using r23 of Google Play Services fixed it for me. Like baldwin said.
Download link:


I think I was also able to fix this by upgrading to Google Analytics v4. I think the core issue is that Google is moving towards putting all their stuff in a single JAR file (the google-play-services.jar). Whereas v3 requires the separate libGoogleAnalyticsServices.jar, v4 just uses the analytics library embedded in google-play-services.jar.

May not be an option for this plugin, but also a potential fix.

semeno commented May 25, 2015

I was stuck for a long time on this one, trying to integrate both Analytics & Ad mob plugins. v23 solved it! Thanks a lot


Thank you for that, using r23 of Google Play Services fixed the problem straight away


Baldwin's last commit: ab62677 is a first-pass at v4 support if anyone wants to give it a try as it relates to the Play Services interaction.


Guysss m facing same issue
m using these dependencies
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile ''
compile ''
compile 'net.the4thdimension:android-utils:2.0.4'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp:2.2.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
compile 'com.nostra13.universalimageloader:parent:1.9.3'
compile 'it.neokree:MaterialNavigationDrawer:1.3'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
compile 'com.malinskiy:superrecyclerview:1.1.0'
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.github.flavienlaurent.datetimepicker:library:0.0.2'
compile 'com.afollestad:material-dialogs:'
compile ''

And m getting same problem
UNEXPECTED TOP-LEVEL EXCEPTION: Multiple dex files define Lcom/google/android/gms/analytics/internal/Command$1;

Please help me, I am just trying to add Google Analytics and n struggling for so many days


Somehow the google analytics v4 doesn't work for me, but downgrading to r23 works fine.

Thanks :)


Yes even I did same ):

cjmling commented Jul 24, 2015

Using r23 worked for me too. Thanks @mauriciotollin for the link

AGulev commented Aug 20, 2015

using r23 doesn't help in my case =(

anat commented Aug 20, 2015

Hi AGulev,

You have two solutions :

  • Open the "google-play-services.jar" with Winrar and go to com/google/android/gms/analytics/internal/
    then remove the two files (java classes) :
    and keep the original libGoogleAnalyticsServices.jar
  • Use mauriciotollin version of "google-play-services.jar"

Note that if you have removed classes from libGoogleAnalyticsServices.jar you should download the original.

I'm about to try this two techniques.

Tell me if I'm wrong, other idea is to use google analytics V4 but the plugin has to be updated.

Good luck and good games

anat commented Aug 20, 2015

Ok it works using mauriciotollin and keep original libGoogleAnalyticsServices.jar from this plugin.
Not that if you have error like
"CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details."
you should try to remove all plugin (jar)/2 of them in your unity Assets/Plugins/Android folder then add 1, then other in order to find which is the problem.


Using r23 worked for me too. Thanks :]


r23 worked for me as well.


How is this still not fixed? @ Android team


@matt-spungegames can send you me the .jar file after deleting the Command.class and Command$1.class

Xerios commented Sep 30, 2015

Pretty much bothering me as well, a fix would be nice.

@TeorikDeli TeorikDeli referenced this issue in playgameservices/play-games-plugin-for-unity Oct 7, 2015

Build Failure: Unable to convert classes into dex format #740

tng2903 commented Oct 12, 2015

so sad, a not-so-complicated error taking too much time to fix, facing this problem as well, please give me back 10hours of my life :(


It's a shame this isn't fixed. GPS is v27 at moment, and downgrading to v23 is bad. Also, v4 is not working on Unity 4.X, what is funny because 90% of mobile developers still use Unity 4.X because performance problems in Unity 5.


@studentvz20 Can you give me the full version of Unity 4.x you are using where it doesn't work and what the problem is you are seeing.


@baldwin628 I'm using Unity 4.6.7.f1. Problem with AnalyticsV4 is that GAv4 prefab file is not usable, I would say that prefab is created in Unity 5 (Unity files created in Unity 5 are not recognized in Unity 4).
Creating Empty Object and adding GoogleAnalyticsV4 script solved this little problem and everything works without any problem.

I tryed this yesterday but then I got some other errors what lead me to thinking about compatibility problems - but I was wrong, my project was broken.


can you post a working solution? if I add a lib from r23, then the admob plugin still does not read the GPS plugin. Do I need to replace the lib to r23 after adding full unity package?


Ok I have the Sollution.

  1. Delete google-play-services_lib from your project
  2. Update Goole Play Service from SDK Manager
  3. After updating go to D:\adt-bundle-windows-x86-20131030\sdk\extras\google\google_play_services\libproject\google-play-services_lib\libs
  4. Open google-play-services.jar with WinRAR and then remove the two files (java classes) :
    Command.class Command$1.class
  5. Drag and drop google-play-services_lib folder from SDK to "Project" window of your Unity3dProject on path Assers\Plugins\Android
  6. ...
  7. PROFIT!!!!
    I have both GAV3 and AdMob banners working now. Whopeee.
proppy commented Oct 26, 2015

FYI, @baldwin628 pointed me to which should fix the conflict issue.

It doesn't show up in releases yet, because there is still work to do to setup the documentation.

But I'm sure more testing would be appreciated.


Any news? When it's crazy issue will be fixed?

Mikleru commented Nov 24, 2015

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.

Locate file \Asstes\GooglePlayGames\Editor\BackgroundResolution.cs
Find selfdescriptive method and add C# lines

    private static void AddDependencies()
     "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


Thank you Mikleru, your solution is the best.
The problem is using the latest version of GooglePlay with latest version of Onesigal.
Adding this on BackgroundResolution solved my problem.

Yukov commented Jan 5, 2016

Guys where you got v4?


Hey Mikleru, they changed the plugin and the class BackgroundResolution.cs doesn't exist anymore.

GPGSDependencies.cs contains similiar code (adding the dependencies), and it manages what .aar files are added. I changed it to include the analytics .aar, and that works. But Google Analytics crashes the app a few seconds after starting it (I assume when it starts actually sending data). I receive no unity errors using logcat -s Unity during this, it just crashes.

I've been stuck on this for awhile now, any ideas on what to do? Both plugins work fine if I compile them without the other, but together, and the google-play-services_lib conflicts with the .aar files. Removing the entire google-play-services_lib probably causes the crash..


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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment