Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

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

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

Comments

@matt-spungegames
Copy link

@matt-spungegames matt-spungegames commented May 4, 2015

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.

@aymericgeffroy
Copy link

@aymericgeffroy aymericgeffroy commented May 4, 2015

Hello,

I had the same problem yesterday !

I solved by open the jar with 7zip and delete 2 files under
com/google/android/gms/analytics/internal/

From memory, it was :
Command.class
Command$1.class

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

Aymeric

@matt-spungegames
Copy link
Author

@matt-spungegames matt-spungegames commented May 5, 2015

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.

@aymericgeffroy
Copy link

@aymericgeffroy aymericgeffroy commented May 5, 2015

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

@aymericgeffroy
Copy link

@aymericgeffroy aymericgeffroy commented May 5, 2015

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

@Zubius
Copy link

@Zubius Zubius commented May 6, 2015

I've deleted this classes from google-play-services.jar instead
Command.class
Command$1.class
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.

@arminelec
Copy link

@arminelec arminelec commented May 7, 2015

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.

@FrankNine
Copy link

@FrankNine FrankNine commented May 11, 2015

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:
playgameservices/play-games-plugin-for-unity#305
Though the developer states that it is harmless, but this message is spamming my logcat and it's really annoying.

@ahmetalsan
Copy link

@ahmetalsan ahmetalsan commented May 11, 2015

I have same issue.

@baldwin628
Copy link
Contributor

@baldwin628 baldwin628 commented May 12, 2015

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.

@matt-spungegames
Copy link
Author

@matt-spungegames matt-spungegames commented May 12, 2015

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.

@baldwin628
Copy link
Contributor

@baldwin628 baldwin628 commented May 12, 2015

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

@matt-spungegames
Copy link
Author

@matt-spungegames matt-spungegames commented May 13, 2015

I’m using the following functions:
GoogleAnalyticsV3.DispatchHits()
GoogleAnalyticsV3.LogException()
GoogleAnalyticsV3.LogEvent()
GoogleAnalyticsV3.LogTiming()
GoogleAnalyticsV3.LogSocial()

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
Copy link

@bivisss bivisss commented May 14, 2015

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

@ghost
Copy link

@ghost ghost commented May 19, 2015

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
Copy link

@semeno 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

@Weasel86
Copy link

@Weasel86 Weasel86 commented Jun 20, 2015

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

@cheneytsai
Copy link

@cheneytsai cheneytsai commented Jun 24, 2015

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.

@niket-sminq
Copy link

@niket-sminq niket-sminq commented Jul 8, 2015

Guysss m facing same issue
m using these dependencies
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:design:22.2.0'
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:0.7.6.0'
compile 'com.google.android.gms:play-services-analytics:7.5.0'
}

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

@timmy2702
Copy link

@timmy2702 timmy2702 commented Jul 11, 2015

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

Thanks :)

@niket-sminq
Copy link

@niket-sminq niket-sminq commented Jul 12, 2015

Yes even I did same ):

@cjmling
Copy link

@cjmling cjmling commented Jul 24, 2015

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

@AGulev
Copy link

@AGulev AGulev commented Aug 20, 2015

using r23 doesn't help in my case =(

@anat
Copy link

@anat 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) :
    Command.class
    Command$1.class
    and keep the original libGoogleAnalyticsServices.jar
    OR
  • 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
Copy link

@anat 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.

@huloo248
Copy link

@huloo248 huloo248 commented Aug 29, 2015

Using r23 worked for me too. Thanks :]

@bitfabrikken
Copy link

@bitfabrikken bitfabrikken commented Aug 30, 2015

r23 worked for me as well.

@LeakedDave
Copy link

@LeakedDave LeakedDave commented Sep 3, 2015

How is this still not fixed? @ Android team

@zahid--ali
Copy link

@zahid--ali zahid--ali commented Sep 21, 2015

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

@Xerios
Copy link

@Xerios Xerios commented Sep 30, 2015

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

@tng2903
Copy link

@tng2903 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 :(

@studentvz20
Copy link

@studentvz20 studentvz20 commented Oct 13, 2015

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.

@baldwin628
Copy link
Contributor

@baldwin628 baldwin628 commented Oct 13, 2015

@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.

@studentvz20
Copy link

@studentvz20 studentvz20 commented Oct 14, 2015

@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.

@protactinium91
Copy link

@protactinium91 protactinium91 commented Oct 23, 2015

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?

@Silmarill
Copy link

@Silmarill Silmarill commented Oct 24, 2015

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
Copy link

@proppy proppy commented Oct 26, 2015

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.

@BestStream
Copy link

@BestStream BestStream commented Nov 1, 2015

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

@Zer0cul
Copy link

@Zer0cul Zer0cul 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.

FIX:
Locate file \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

@mrpacogp
Copy link

@mrpacogp mrpacogp commented Dec 19, 2015

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
Copy link

@Yukov Yukov commented Jan 5, 2016

Guys where you got v4?

@Zer0cul
Copy link

@Zer0cul Zer0cul commented Jan 6, 2016

Hi, Yukov
Please take a look
https://github.com/googleanalytics/google-analytics-plugin-for-unity
In root directory file name:
GoogleAnalyticsV4.unitypackage

or direct link

https://github.com/googleanalytics/google-analytics-plugin-for-unity/blob/master/GoogleAnalyticsV4.unitypackage

@DuskLightStudios
Copy link

@DuskLightStudios DuskLightStudios commented Mar 20, 2016

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..

@christianstrang
Copy link

@christianstrang christianstrang commented Apr 22, 2016

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests