Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Play Games doesn't work with Admob

Discussion in 'Android' started by ycanatilgan, May 27, 2020.

  1. ycanatilgan

    ycanatilgan

    Joined:
    Aug 23, 2017
    Posts:
    30
    So I try to add Play games plugin to my project but when I try to sign in the user with;
    Code (CSharp):
    1. Social.localUser.Authenticate(success => {  });
    This error appears on Android:

    AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.games.Games
    java.lang.ClassNotFoundException: com.google.android.gms.games.Games
    at java.lang.Class.classForName(Native Method)
    at java.lang.Class.forName(Class.java:453)
    at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
    at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0)
    at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:83)
    at android.os.Handler.dispatchMessage(Handler.java:104)
    at android.os.Looper.loop(Looper.java:166)
    at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
    Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.games.Games" on path: DexPathList[[zip file "/data/app/com.blabla.blabla-.......==/base.apk"],nativeLibraryDirectories=[/data/app/com.blablabla.blabla....==/lib/arm, /data/app/com.blablabla.blablabla==/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib, /pr


    I tried removing and re-importing play games package, installing different play games versions and force resolving but none of them worked. I tried to install Play Games into a blank project and it worked there properly. I already have admob plugin in my project so probably something wrong with it.

    Any ideas?
     
    hopetolive likes this.
  2. Anshu06

    Anshu06

    Joined:
    Jun 5, 2020
    Posts:
    1
    YaFebest, hantengx and hopetolive like this.
  3. ycanatilgan

    ycanatilgan

    Joined:
    Aug 23, 2017
    Posts:
    30
    hopetolive likes this.
  4. john1sta

    john1sta

    Joined:
    Dec 2, 2013
    Posts:
    1
    Thanks!! you just saved me!:):)
     
  5. userq

    userq

    Joined:
    Jun 4, 2017
    Posts:
    40
    Hi, I am using these versions of unity and the plugin and I am getting the same error.
    I dont use Admob though just the play services plugin.

    The solution with the custom proguard does not work anymore. How I can resolve this?
    • Unity version: 2021.3.2 LTS
    • Google Play Games Plugin: 0.11.01
     
    Last edited: May 18, 2022
  6. userq

    userq

    Joined:
    Jun 4, 2017
    Posts:
    40
    It looks like leaving only the Debug checkbox (On) for the minification solves the problem.
     
  7. Steviebops

    Steviebops

    Joined:
    Apr 9, 2013
    Posts:
    132
    Im having the same issue and leaving the debug check on no longer works.
    any updates for this?
     
  8. AkiSharma

    AkiSharma

    Joined:
    Nov 20, 2016
    Posts:
    1
  9. Steviebops

    Steviebops

    Joined:
    Apr 9, 2013
    Posts:
    132
    I found a solution, you need to have a custom proguard file, and do NOT use Force Resolve.
    Use Resolve only, and the text file is this:


    -keep class com.google.unity.**{*;}
    -keep public class com.google.android.gms.ads.**{public *;}
    -keep public class com.google.ads.**{public *;}
    -keep class com.google.android.gms.games.leaderboard.** { ; }
    -keep class com.google.android.gms.games.snapshot.* { ; }
    -keep class com.google.android.gms.games.achievement.* { ; }
    -keep class com.google.android.gms.games.event.* { ; }
    -keep class com.google.android.gms.games.stats.* { ; }
    -keep class com.google.android.gms.games.video.* { ; }
    -keep class com.google.android.gms.games. { ; }
    -keep class com.google.android.gms.common.api.ResultCallback { ; }
    -keep class com.google.android.gms.signin. { ; }
    -keep class com.google.android.gms.dynamic.* { ; }
    -keep class com.google.android.gms.dynamite.* { ; }
    -keep class com.google.android.gms.tasks.* { ; }
    -keep class com.google.android.gms.security.* { ; }
    -keep class com.google.android.gms.base.* { ; }
    -keep class com.google.android.gms.actions.* { ; }
    -keep class com.google.games.bridge.* { ; }
    -keep class com.google.android.gms.common.ConnectionResult { ; }
    -keep class com.google.android.gms.common.GooglePlayServicesUtil { ; }
    -keep class com.google.android.gms.common.api. { ; }
    -keep class com.google.android.gms.common.data.DataBufferUtils { ; }
    -keep class com.google.android.gms.games.quest. { ; }
    -keep class com.google.android.gms.nearby. { *; }
    -keepattributes *Annotation*
    -dontobfuscate
     
  10. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    338
    In my case I removed -dontobfuscate.
     
  11. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    338
    and used (2020.3.36f1):

    -keep class com.google.android.gms.games.leaderboard.** { *; }
    -keep class com.google.android.gms.games.snapshot.** { *; }
    -keep class com.google.android.gms.games.achievement.** { *; }
    -keep class com.google.android.gms.games.event.** { *; }
    -keep class com.google.android.gms.games.stats.** { *; }
    -keep class com.google.android.gms.games.* { *; }
    -keep class com.google.android.gms.common.api.ResultCallback { *; }
    -keep class com.google.android.gms.signin.** { *; }
    -keep class com.google.android.gms.dynamic.** { *; }
    -keep class com.google.android.gms.dynamite.** { *; }
    -keep class com.google.android.gms.tasks.** { *; }
    -keep class com.google.android.gms.security.** { *; }
    -keep class com.google.android.gms.base.** { *; }
    -keep class com.google.android.gms.actions.** { *; }
    -keep class com.google.games.bridge.** { *; }
    -keep class com.google.android.gms.common.ConnectionResult { *; }
    -keep class com.google.android.gms.common.GooglePlayServicesUtil { *; }
    -keep class com.google.android.gms.common.api.** { *; }
    -keep class com.google.android.gms.common.data.DataBufferUtils { *; }
    -keep class com.google.android.gms.nearby.** { *; }
    -keep class com.google.unity.**{*;}
    -keep public class com.google.android.gms.ads.**{public *;}
    -keep public class com.google.ads.**{public *;}
    -keepattributes *Annotation*
     
  12. Steviebops

    Steviebops

    Joined:
    Apr 9, 2013
    Posts:
    132
    Is it working for you?
     
  13. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    338
    For me?

    It was one of a few issues, I have it working now. FYI, I am using unity mediation, which was using admob.
     
    Steviebops likes this.
  14. Sayrex_Games

    Sayrex_Games

    Joined:
    Aug 1, 2013
    Posts:
    1

    It helped me!

    Unity 2021.3.15f1 + Admob 7.3.0

    Thanks