使用Unity 2018的Google Play服务排行榜错误(java.lang.ClassNotFoundException:com.google.games.bridge.TokenFragment)

时间:2019-01-01 17:11:48

标签: java google-play google-play-services classnotfoundexception android-unity-plugin

我想使用Unity在Android移动应用中实现排行榜。

我正在使用:

  • Unity 2018.2.18f1(Mac)

  • Java开发工具包(jdk.1.8.0_191)

  • Google Play游戏插件0.9.57 [当前版本1.1.2019]

Google Play服务已成功激活(应用内购买可以正常工作),但是在尝试使排行榜功能正常工作时,我一直收到此错误:

java.lang.ClassNotFoundException: com.google.games.bridge.TokenFragment

进一步(为了清楚起见:我用XXXX替换了应用名称):

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.games.bridge.TokenFragment" on path: DexPathList[[zip file "/data/app/com.NGDD.XXXX-1/base.apk"],nativeLibraryDirectories=[/data/app/com.NGDD.XXXX-1/lib/arm, /data/app/com.NGDD.XXXX

2019-01-01 17:48:52.784 15145-15145/com.NGDD.XXXX W/System: ClassLoader referenced unknown path: /system/framework/QPerformance.jar
2019-01-01 17:48:52.785 15145-15145/com.NGDD.XXXX E/BoostFramework: BoostFramework() : Exception_1 = java.lang.ClassNotFoundException: Didn't find class "com.qualcomm.qti.Performance" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib, /vendor/lib]]

...这导致:

*** [Play Games Plugin DLL] 01/01/19 17:51:50 +01:00 ERROR: ShowLeaderboardUI can only be called after authentication.
  • 我尝试了不同的构建类型(内部和gradle)。
  • 我在Google Play内部和Alpha测试人员上发布了该应用,并将该设备的Google帐户设置为测试帐户

我试图检查SHA-1证书,但不知道如何从Mac上的Google Play控制台检查和匹配Keystore和SHA-1。

这是场景在Unity中加载时正在执行的代码:

void ActivateGooglePlayServices()
{
    PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().RequestIdToken().Build();
    PlayGamesPlatform.InitializeInstance(config);
    PlayGamesPlatform.Activate();
    LoginToGooglePlay();

}

public void LoginToGooglePlay()
{
    ((PlayGamesPlatform)Social.Active).localUser.Authenticate((bool success) =>
    {
        if (success)
        {
            Debug.Log("!!! Login Success !!!");
        }
        else
        {
            Debug.Log("!!! login failed !!! ");
        }
    });
}

排行榜调用如下:

public void ShowLeaderBoard()
{
    // this didn't work at all: --> ((PlayGamesPlatform)Social.Active).ShowLeaderboardUI (leaderboard_ID);
    // The following line throws: *** [Play Games Plugin DLL] 01/01/19 17:51:50 +01:00 ERROR: ShowLeaderboardUI can only be called after authentication.
    Social.ShowLeaderboardUI();

}

带有NullReferenceException错误的整个部分,我无法理解:

 2019-01-01 18:00:56.564 16197-16236/com.NGDD.XXXX W/Unity: *** [Play Games Plugin DLL] 01/01/19 18:00:56 +01:00 ERROR: UnityEngine.AndroidJavaException: java.lang.ClassNotFoundException: com.google.games.bridge.TokenFragment
java.lang.ClassNotFoundException: com.google.games.bridge.TokenFragment
    at java.lang.Class.classForName(Native Method)
    at java.lang.Class.forName(Class.java:400)
    at java.lang.Class.forName(Class.java:326)
    at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
    at com.unity3d.player.UnityPlayer.c(Unknown Source)
    at com.unity3d.player.UnityPlayer$e$2.queueIdle(Unknown Source)
    at android.os.MessageQueue.next(MessageQueue.java:392)
    at android.os.Looper.loop(Looper.java:136)
    at com.unity3d.player.UnityPlayer$e.run(Unknown Source)
 Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.games.bridge.TokenFragment" on path: DexPathList[[zip file "/data/app/com.NGDD.XXXX-2/base.apk"],nativeLibraryDirectories=[/data/app/com.NGDD.XXXX-2/lib/arm, /data/app/com.NGDD.XXXX
2019-01-01 18:00:56.613 16197-16805/com.NGDD.XXXX W/google-breakpad: ### ### ### ### ### ### ### ### ### ### ### ### ###
2019-01-01 18:00:56.613 16197-16805/com.NGDD.XXXX W/google-breakpad: Chrome build fingerprint:
2019-01-01 18:00:56.613 16197-16805/com.NGDD.XXXX W/google-breakpad:71.0.3578.99
2019-01-01 18:00:56.613 16197-16805/com.NGDD.XXXX W/google-breakpad:357809952
2019-01-01 18:00:56.613 16197-16805/com.NGDD.XXXX W/google-breakpad:### ### ### ### ### ### ### ### ### ### ### ### ###
2019-01-01 18:00:56.614 16197-16805/com.NGDD.XXXX E/mono: Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object
  at UnityEngine.AndroidJavaObject.Dispose (Boolean disposing) [0x00007] in /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:230 
  at UnityEngine.AndroidJavaObject.Finalize () [0x00003] in /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:225 

预期的结果是调用ShowLeaderBoard()时会弹出Google页首横幅用户界面。

1 个答案:

答案 0 :(得分:1)

好几天我都遇到过同样的问题,只是想通了。

如果项目路径名中包含特殊字符,则它将无法解析。

我的项目有一个带有“!”的文件夹。在路径名中,我只是简单地重命名了该文件夹,并确保不要使用空格或特殊字符,它现在可以使用!

我希望这也能解决您的问题!