使用Unity 2018的Google Play服务排行榜错误(java.lang.ClassNotFoundExcep



我想使用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.
  • 我尝试了不同的构建类型(内部和渐变)
  • 我在Google Play上为内部和Alpha测试人员发布了该应用程序,该设备的谷歌帐户设置为测试帐户

我试图检查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()时弹出谷歌排行榜UI。

我遇到了同样的问题好几天了,刚刚解决了。

如果项目路径名中有一个特殊字符,则无法解析。

我的项目有一个路径名为"!"的文件夹,我只是简单地重命名了文件夹,并确保不使用空格或特殊字符,现在就可以使用了!

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

相关内容

  • 没有找到相关文章

最新更新