googleanalytics / google-analytics-plugin-for-unity

Google Analytics plugin for the Unity game creation system

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Google Play Games Compatibility

DuskLightStudios opened this issue · comments

I ran into an issue regarding the compatibility between Google Analytics and Google Play Games services. After a lot of experimenting and research, I've figured out that the issue is about the Google Play Services library.

Google Play Games removes this library and replaces it with .aar files. Theoretically a good idea, since it clears up a lot of app size. But it breaks Google Analytics, which needs that library to function.

I've tried including the analytics aar file into the dependencies, as described here:
#51

But that didn't work. The result is that Google Play Games works, but the app crashes after a few seconds due to Google Analytics. My Google Analytics works great if Google Play Games is not included in the game.

A lot of people seem to have this issue, but there seems to be no clear solution for it anywhere. What can I do to fix this?

Problem resolved. I didn't expect to find it this quickly. Apologies for somewhat hastely posting about this issue!
I actually solved the issue awhile back, but I believed the solution didn't work because a completely different bug was crashing my app the entire time. So after solving that, I discovered my issue was already gone.

The only thing you need to do to get Google Analytics to work with Google PlayGames is:

  1. Install Google Analytics as described in their readme
  2. Install Google PlayGames as described in their readme
  3. Don't add the 'google-play-services_lib' folder in 'Assets/Plugins/Android', and if you did, simply delete it.
  4. Add the following code to GPGSDependencies.cs

svcSupport.DependOn("com.google.android.gms",
"play-services-analytics",
PluginVersion.PlayServicesVersionConstraint);

That should remove the compatibility issue, and allow you to run the code.
Do make sure both plugins work independently first. Otherwise, you might get a problem with one of them, and believe it's about compatibility.

Thanks it save my time

I had a similar issue, and I solved it adding all the Google libs at the same version.

I.

screen shot 2016-06-07 at 12 18 37

DuskLightStudios your way doesnt solve my problem. I have last version of google analytics (V4) and also last version of google play game service ( 9.34). In editor no problem but in android i took this exception from logging with adb:

java.lang.NoSuchMethodError: No static method zzy(Ljava/lang/Object;)Ljava/lang/Object; in class Lcom/google/android/gms/common/internal/zzab; or its super classes (declaration of 'com.google.android.gms.common.internal.zzab' appears in /data/app/com.HTGames.blinkblock-2/base.apk)
09-29 18:41:40.941 10507 10538 I Unity : at com.google.android.gms.analytics.internal.zzf.zzay(Unknown Source)
09-29 18:41:40.941 10507 10538 I Unity : at com.google.android.gms.analytics.GoogleAnalytics.getInstance(Unknown Source)
09-29 18:41:40.941 10507 10538 I Unity : at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
09-29 18:41:40.941 10507 10538 I Unity : at com.unity3d.player.UnityPlayer.a(Unknown Source)
09-29 18:41:40.941 10507 10538 I Unity : at com.unity3d.player.UnityPlayer$b$1.handleMessage(Unknown Source)
09-29 18:41:40.941 10507 10538 I Unity : at android.os.Handler.dispatchMessage(Handler.java:98)
09-29 18:41:40.941 10507 10538 I Unity : at android.os.Looper.loop(Looper.java:158)

if you have an idea i will be really grateful

just edit AndroidManifest file and set min sdk and target sdk