Play-games-plugin-for-unity: [Play Games Plugin DLL] ERROR: Exception launching token request: java.lang.ClassNotFoundException: com.google.games.bridge.TokenFragment

Created on 7 Jun 2019  路  8Comments  路  Source: playgameservices/play-games-plugin-for-unity

I am having an issue where I can't get a connection to GooglePlayGames working, every time it tries to connect it throws this error. I have included the relevant snippet of the catlog below.

I am using Unity 2018.3.8f1 running on Windows, android platform.

  • Gradle 4.6
  • ndk r16b
  • IL2CPP
  • open JDK 1.8.0_152
  • The app use firebase 5.4.4 (I have tried updating to 6.0.0, but get same issue).
  • it also uses facebook sdk (but I have also tried removing it, and encounter the same issue)

The code is being called in an asynchronous function.

Code Snippet

        PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
            .RequestServerAuthCode(false /* Don't force refresh */)
            .Build();
        try
        {
            PlayGamesPlatform.InitializeInstance(config);
            PlayGamesPlatform.Activate();
        }

Error Log

06-06 16:59:21.814 28685 28857 W Unity : GooglePlayGames.OurUtils.PlayGamesHelperObject:Update()
06-06 16:59:21.814 28685 28857 W Unity :
06-06 16:59:21.814 28685 28857 W Unity : (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)
06-06 16:59:21.814 28685 28857 W Unity :
06-06 16:59:21.828 28685 28857 W Unity : * [Play Games Plugin DLL] 06/06/19 16:59:21 -07:00 ERROR: Exception launching token request: java.lang.ClassNotFoundException: com.google.games.bridge.TokenFragment
06-06 16:59:21.828 28685 28857 W Unity : GooglePlayGames.OurUtils.PlayGamesHelperObject:Update()
06-06 16:59:21.828 28685 28857 W Unity :
06-06 16:59:21.828 28685 28857 W Unity : (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)
06-06 16:59:21.828 28685 28857 W Unity :
06-06 16:59:21.830 28685 28857 W Unity : *
[Play Games Plugin DLL] 06/06/19 16:59:21 -07:00 ERROR: UnityEngine.AndroidJavaException: java.lang.ClassNotFoundException: com.google.games.bridge.TokenFragment
06-06 16:59:21.830 28685 28857 W Unity : at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0
06-06 16:59:21.830 28685 28857 W Unity : at UnityEngine.AndroidJNISafe.CallStaticObjectMethod (System.IntPtr clazz, System.IntPtr methodID, UnityEngine.jvalue[] args) [0x00000] in <00000000000000000000000000000000>:0
06-06 16:59:21.830 28685 28857 W Unity : at UnityEngine.AndroidJavaObject._CallStatic[ReturnType] (System.String methodName, System.Object[] args) [0x00000] in <00000000000000000000000000000000>:0
06-06 16:59:21.830 28685 28857 W Unity : at UnityEngine.AndroidJavaClass._AndroidJavaClass (System.String className) [0x00000] in <00000000000000000000000000000000>:0
06-06 16:59:21.830 28685 28857 W Unity : at GooglePlayGames.Android.AndroidTokenClient.DoFetchToken (System.Boolean silent, System.Action`1[T] callback) [0x00000] in <00000000000000000000000000000000>:0
06-06 16:59:21.830 28685 28857 W Unity : at GooglePlayGames.OurUtils.PlayGamesHelperObject.Update () [0x00000] in <00000000000000000000000000000000>:0
06-06 16:59:21.830 28685 28857 W Unity : GooglePlayG

Most helpful comment

I have been trying to get my apps ready to be meet the August deadline for 64-bit compliance on Google Play. In doing that for my second game, I encountered the TokenFragment problem again. I thought for sure I had already taken steps that would avoid this by converting to 0.9.64 of the Play Games plugin setting up Gradle build and Proguard. Turns out I was mistaken. I still needed to update the unity-jar-resolver: https://github.com/googlesamples/unity-jar-resolver
I updated to 1.2.117 and then did resolve (or Force Resolve).

So if you are using Gradle build and Proguard, try that.

All 8 comments

Same here. Also using IL2CPP.

Versions:
Google Play Games for Unity 0.9.64
Unity 2019.1.4f1
Firebase 6.0.0
Facebook 7.15.1

ADB Logcat:
2019-06-12 18:44:55.494 12384-12474/? W/Unity: *** [Play Games Plugin DLL] 06/12/19 18:44:55 +03:00 ERROR: Exception launching token request: java.lang.ClassNotFoundException: com.google.games.bridge.TokenFragment (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 48) 2019-06-12 18:44:55.495 12384-12474/? W/Unity: *** [Play Games Plugin DLL] 06/12/19 18:44:55 +03:00 ERROR: UnityEngine.AndroidJavaException: java.lang.ClassNotFoundException: com.google.games.bridge.TokenFragment at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.AndroidJNISafe.CallStaticObjectMethod (System.IntPtr clazz, System.IntPtr methodID, UnityEngine.jvalue[] args) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.AndroidJavaObject._CallStatic[ReturnType] (System.String methodName, System.Object[] args) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.AndroidJavaClass._AndroidJavaClass (System.String className) [0x00000] in <00000000000000000000000000000000>:0 at GooglePlayGames.Android.AndroidTokenClient.DoFetchToken (System.Boolean silent, System.Action1[T] callback) [0x00000] in <00000000000000000000000000000000>:0
at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0
at GooglePlayGames.OurUtils.PlayGamesHelpe
`

So I was able to "get around" this issue, by playing with the android play services resolver.
Trying different combinations of:

  • Delete Resolved Libraries
  • Force Resolve
  • Resolve
    Manually updating the resolver (the update doesn't seem to do anything)

I was eventually able to get it into a state where it would try to connect (an no longer throw this error).

Sorry for no clear "fix" my "solution" was trying over and over again different combinations of resolver calls and then one time it worked, and then continued to work.

Hi , I experience the same problem , can you show me your gradle file ? as well as the library u're currently using :D

It seems that gradle is not be able to copying com.google.games:gpgs-plugin-support:0.9.64 from Unity project. I had exported APK and check the classes.dex and there is no google play game there.

Remove the using for gradle template and forced resolve can solve this problem

Ok so turn off pro-guard and gradle template solved the bug

I have been trying to get my apps ready to be meet the August deadline for 64-bit compliance on Google Play. In doing that for my second game, I encountered the TokenFragment problem again. I thought for sure I had already taken steps that would avoid this by converting to 0.9.64 of the Play Games plugin setting up Gradle build and Proguard. Turns out I was mistaken. I still needed to update the unity-jar-resolver: https://github.com/googlesamples/unity-jar-resolver
I updated to 1.2.117 and then did resolve (or Force Resolve).

So if you are using Gradle build and Proguard, try that.

I have been trying to get my apps ready to be meet the August deadline for 64-bit compliance on Google Play. In doing that for my second game, I encountered the TokenFragment problem again. I thought for sure I had already taken steps that would avoid this by converting to 0.9.64 of the Play Games plugin setting up Gradle build and Proguard. Turns out I was mistaken. I still needed to update the unity-jar-resolver: https://github.com/googlesamples/unity-jar-resolver
I updated to 1.2.117 and then did resolve (or Force Resolve).

So if you are using Gradle build and Proguard, try that.

unity-jar-resolver updare to 1.2.117 can resolve the problem

Was this page helpful?
0 / 5 - 0 ratings