You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Unity集成Google Play Games登录失败:ClassNotFoundException问题解决

问题:Google Play Games登录ClassNotFoundException异常解决及替代云存档方案

问题背景

我正在开发一款Android游戏,计划用Google Play Games实现云存档功能。已将Google Play Games SDK导入Unity,且按照Unity官方登录教程完成全流程配置——包括添加Android和Web的OAuth信息、将自身设为测试人员,但在设备上测试时登录功能完全失效。调试定位到问题出在代码行PlayGamesPlatform.Activate();。

相关代码片段

仅展示Start()中调用的登录初始化方法:

void initialLogIn()
{
    debugText.text += "Begin Log In | ";
    //Initialize PlayGamesPlatform
    PlayGamesPlatform.Activate();
    PlayGamesPlatform.DebugLogEnabled = true;
    debugText.text += "Activate Play Games Platform | ";
    LoginGooglePlayGames();
}

错误日志

预期游戏启动时自动弹出Google Play账号登录弹窗,但实际无任何弹窗出现。查看Android LogCat得到核心错误:

2024-07-21 22:41:25.959 23612 23673 Error Unity AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames
2024-07-21 22:41:25.959 23612 23673 Error Unity java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames
2024-07-21 22:41:25.959 23612 23673 Error Unity     at java.lang.Class.classForName(Native Method)
2024-07-21 22:41:25.959 23612 23673 Error Unity     at java.lang.Class.forName(Class.java:536)
2024-07-21 22:41:25.959 23612 23673 Error Unity Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.games.PlayGames" on path: DexPathList[[zip file "/data/app/~~kEIMtZEHFF7OzIloMOW6LQ==/com.barkunjgames.dressipher-j24w2j_UTad-VS-G0swCrA==/base.apk"],nativeLibraryDirectories=[/data/app/~~kEIMtZEHFF7OzIloMOW6LQ==/com.barkunjgames.dressipher-j24w2j_UTad-VS-G0swCrA==/lib/arm64, /data/app/~~kEIMtZEHFF7OzIloMOW6LQ==/com.barkunjgames.dressipher-j24w2j_UTad-VS-G0swCrA==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
2024-07-21 22:41:25.959 23612 23673 Error Unity     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
2024-07-21 22:41:25.959 23612 23673 Error Unity     at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
2024-07-21 22:41:25.959 23612 23673 Error Unity     at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
2024-07-21 22:41:25.959 23612 23673 Error Unity     ... 2 more
2024-07-21 22:41:25.959 23612 23673 Error Unity   at UnityEngine.AndroidJNISafe.CheckExceptio

此外LogCat中还出现gralloc4相关错误,暂不确定是否关联:

2024-07-21 22:41:23.171 23612 23673 Error gralloc4 ERROR: Format allocation info not found for format: 3b
2024-07-21 22:41:23.171 23612 23673 Error gralloc4 ERROR: Format allocation info not found for format: 0
2024-07-21 22:41:23.171 23612 23673 Error gralloc4 Invalid base format! req_base_format = (<unrecognized format> 0x0), req_format = (<unrecognized format> 0x3b), type = 0x0
2024-07-21 22:41:23.171 23612 23673 Error gralloc4 ERROR: Unrecognized and/or unsupported format (<unrecognized format> 0x3b) and usage (CPU_READ_NEVER|CPU_WRITE_NEVER|GPU_TEXTURE|GPU_RENDER_TARGET|COMPOSER_OVERLAY 0xb00)
2024-07-21 22:41:23.171 23612 23673 Error gralloc4 ERROR: Format allocation info not found for format: 3b
2024-07-21 22:41:23.171 23612 23673 Error gralloc4 ERROR: Format allocation info not found for format: 0
2024-07-21 22:41:23.171 23612 23673 Error gralloc4 Invalid base format! req_base_format = (<unrecognized format> 0x0), req_format = (<unrecognized format> 0x3b), type = 0x0
2024-07-21 22:41:23.171 23612 23673 Error gralloc4 ERROR: Unrecognized and/or unsupported format (<unrecognized format> 0x3b) and usage (CPU_READ_NEVER|CPU_WRITE_NEVER|GPU_TEXTURE|GPU_RENDER_TARGET|COMPOSER_OVERLAY 0xb00)

已尝试的解决步骤

  • 查阅其他Google登录教程,确认是否遗漏配置步骤或存在其他代码实现方式
  • 搜索公开解决方案,尝试了GitHub相关问题下的评论建议
  • 使用Mobile Dependency Resolver/External Dependency Resolver的Force Resolve功能
  • 咨询程序员同行

核心问题

  1. 如何解决AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames异常,实现Google Play账号正常登录?
  2. 若该问题无法解决,有哪些可替代的云存档方案可选?

内容的提问来源于stack exchange,提问作者Jeffrey Barkun

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 15:44:53