The google analytics plugin appears to conflict with the google play games plugin.
With both plugins installed in a project, these two jar files:
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" -
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/analytics/internal/Command;
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
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.
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.
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?
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
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.
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
compile fileTree(include: ['*.jar'], dir: 'libs')
And m getting same problem
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: 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.
Yes even I did same ):
Using r23 worked for me too. Thanks @mauriciotollin for the link
using r23 doesn't help in my case =(
You have two solutions :
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
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
Pretty much bothering me as well, a fix would be nice.
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.
FYI, @baldwin628 pointed me to https://github.com/googleanalytics/google-analytics-plugin-for-unity/blob/master/GoogleAnalyticsV4.unitypackage 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?
My configuration is:
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-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.
Guys where you got v4?
Please take a look
In root directory file name:
or direct link
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...