I'm trying to run the following code as part of an initialization function in my game:
```C#
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
// enables saving game progress.
.EnableSavedGames()
// requests a server auth code be generated so it can be passed to an
// associated back end server application and exchanged for an OAuth token.
.RequestServerAuthCode(false)
// requests an ID token be generated. This OAuth token can be used to
// identify the player to other services such as Firebase.
.RequestIdToken()
.Build();
Debug.Log( $"GoogleGameManager, init: 1." );
PlayGamesPlatform.InitializeInstance(config);
// recommended for debugging:
Debug.Log( $"GoogleGameManager, init: 2." );
PlayGamesPlatform.DebugLogEnabled = true;
// Activate the Google Play Games platform
Debug.Log( $"GoogleGameManager, init: 3." );
PlayGamesPlatform.Activate();
Debug.Log( $"GoogleGameManager, init: 4." );
Social.localUser.Authenticate( (bool success) => {
// handle success or failure
Debug.Log( $"Social.localUser.Authenticate, success: {success}." );
if ( success )
{
((PlayGamesLocalUser)Social.localUser).GetStats((rc, stats) =>
{
// -1 means cached stats, 0 is succeess
// see CommonStatusCodes for all values.
if (rc <= 0 && stats.HasDaysSinceLastPlayed()) {
Debug.Log("It has been " + stats.DaysSinceLastPlayed + " days");
}
});
}
});
Debug.Log( $"GoogleGameManager, init: 5." );
The log showing the following results:
```log
2019-12-02 16:57:53.969 8017-8694/? I/Unity: GoogleGameManager, init: 1.
GoogleGameManager:init()
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
2019-12-02 16:57:53.969 8017-8772/? I/UnityAds: com.unity3d.services.core.configuration.InitializeThread$InitializeStateLoadCache.execute() (line:245) :: Unity Ads init: webapp loaded from local cache
2019-12-02 16:57:53.973 8017-8694/? I/Unity: GoogleGameManager, init: 2.
GoogleGameManager:init()
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
2019-12-02 16:57:53.975 8017-8694/? I/Unity: GoogleGameManager, init: 3.
GoogleGameManager:init()
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
2019-12-02 16:57:53.978 8017-8694/? I/Unity: GoogleGameManager, init: 4.
GoogleGameManager:init()
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
2019-12-02 16:57:53.988 8017-8694/? E/Unity: 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.c(Unknown Source:0)
at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95)
at android.os.Handler.dispatchMessage(Handler.java:101)
at android.os.Looper.loop(Looper.java:164)
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.sdfsdfsdfsd.jfgjfghjfgjfg-SEDFSDFGSDGSDGSDF-lA==/base.apk", zip file "/data/app/com.sdfsdfsdfsd.jfgjfghjfgjfg-SEDFSDFGSDGSDGSDF-lA==/split_config.arm64_v8a.apk"],nativeLibraryDirectories=[/data/app/com.sdfsdfsdfsd.jfgjfghjfgjfg-SEDFSDFGSDGSDGSDF
2019-12-02 16:57:53.997 8017-8017/? W/ResourceType: Found multiple library tables, ignoring...
2019-12-02 16:57:53.999 8017-8017/? I/WebViewFactory: Loading com.android.chrome version 78.0.3904.108 (code 390410837)
2019-12-02 16:57:54.001 8017-8694/? I/Unity: Initializing UnityPurchasing via Codeless IAP
UnityEngine.Purchasing.CodelessIAPStoreListener:CreateCodelessIAPStoreListenerInstance()
UnityEngine.Purchasing.CodelessIAPStoreListener:get_Instance()
UnityEngine.Purchasing.IAPListener:OnEnable()
It seems that Social.localUser.Authenticate causing the exception, and login to Google Games never appears. Everything else in my game works fine. I'm also using IAP and Ads packages by Unity.
I'm using PGPfU for the first time, so I'm not sure if I'm doing something wrong, or is it a bug.
Versions: PGPfU 0.10.06 from today, Unity 2019.2.14f, on Ubuntu 19.10 Linux 5.3.0-23-generic.
Any suggestions?
I downgraded to GPGfU v0.9.64, and running the same code, but exception disappeared.
So It looks more like a bug(runtime or setup) in GPGfU v0.10.06 and not that I am doing something wrong.
There are a lot of fixes from v9 to v10, it is better to upgrade to it. Force resolve should help with this issue.
If force resolve didn't help, how can i fix it?
Check if minify setting is set up correctly. Check this README.md section, please.
For whatever reason, that link took me to entirely the wrong section. Just so anyone having that issue doesn't have to inspect the link, it should go to Decreasing APK Size
Having said that, I just upgraded from 10.05 to 10.06 to try and resolve the ClassNotFoundException.
Managed Stripping Level: Disabled
Minify Release: None
Minify Debug: None
Re-ran Android Setup which said "Resolution Succeeded".
Tried running a Force Resolve (which is in Assets menu -> Play Services Resolver -> Android Resolver, if you are wondering like I was), and that didn't work when doing my normal procedure.
I did get it working though!
When I was running Force Resolve, I would get a Jetifier prompt asking to upgrade to API level 28 (from 27). I did not wish to make any significant changes, so I was saying no to this. However, after I said yes, this error went away. I am having a new issue now, but got past this one, and the Google Play Games connection dialog is showing up at least.
Check if minify setting is set up correctly. Check this README.md section, please.
It works for me. Unity version: 2019.2.21f1 , Gpgs version: 10.06, Firebase sdk version: 6.11.0, Admob version: 4.2.1. I spend all the time to solve this problem(Class not found : com.google.android.gms.games). You saved my life. Follow the minify setting.
(player setting > publishing settings >
Hope my case helps some one like me.
Hope my case helps some one like me.
OMG I could kiss you right now!
Check if minify setting is set up correctly. Check this README.md section, please.
It works for me. Unity version: 2019.2.21f1 , Gpgs version: 10.06, Firebase sdk version: 6.11.0, Admob version: 4.2.1. I spend all the time to solve this problem(Class not found : com.google.android.gms.games). You saved my life. Follow the minify setting.
(player setting > publishing settings >
- minify release : proguard,
- minify debug : proguard,
- Check 'user proguard file' enable,
- Copy and paste the text(in the link on the top) into the file(Assets\Plugins\Android\proguard-user.txt)).
Hope my case helps some one like me.
Thanks a lot, mate! This really, really helped! 馃憤
I'm running into this problem. I've tried the proguard update and it's not helping. Any new updates?
I (obviously) got this error when I forgot to Resove after having to reinstall Unity and re-clone my project.
Most helpful comment
It works for me. Unity version: 2019.2.21f1 , Gpgs version: 10.06, Firebase sdk version: 6.11.0, Admob version: 4.2.1. I spend all the time to solve this problem(Class not found : com.google.android.gms.games). You saved my life. Follow the minify setting.
(player setting > publishing settings >
Hope my case helps some one like me.