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

初始化LicensingServiceHelper时Android APK崩溃问题求助

问题分析与解决方案

从日志的java.lang.ClassNotFoundException: com.google.licensingservicehelper.LicensingServiceHelper可以看出,核心问题是运行时找不到指定类,结合你的项目配置,以下是针对性的排查和解决步骤:

1. 修正包名引用错误

日志中查找的类路径是com.google.licensingservicehelper.LicensingServiceHelper,但你的LicensingServiceHelper是自定义本地模块licensingservicehelper中的类,不可能属于com.google包:

  • 打开PlayGameServicesGodot.kt第239行,检查LicensingServiceHelper的导入语句,确认包名和实际类的包名完全一致(比如如果licensingservicehelper模块的namespace是io.cgisca.godot.licensing,导入语句应该是import io.cgisca.godot.licensing.LicensingServiceHelper)。
  • 检查Kotlin代码中实例化类的语句,有没有写错类的全限定名。

2. 确保主AAR包含依赖模块代码

你的主模块使用implementation project(":licensingservicehelper")依赖本地模块,implementation的依赖只会在编译时生效,不会将依赖模块的代码打包进主AAR中,导致Godot导出APK后缺少该类:

  • 修改主模块build.gradle中的依赖声明:
    // 替换原来的implementation
    api project(":licensingservicehelper")
    
  • 重新构建主AAR(执行./gradlew assembleRelease),替换Godot项目中旧的AAR文件。

3. 检查Godot导入与导出配置

  • 确认Godot项目中导入的是最新构建的AAR文件,若licensingservicehelper模块单独打包成AAR,需要将该AAR也一并导入Godot的android/libs目录下。
  • 若Godot导出APK时开启了代码混淆(即使主模块minifyEnabled=false),需在混淆规则文件中添加保留类的规则,替换为实际包名:
    -keep class 你的LicensingServiceHelper全限定包名.LicensingServiceHelper { *; }
    

4. 验证模块包名一致性

检查licensingservicehelper模块的build.gradle中的namespace配置,确保LicensingServiceHelper.java文件顶部的package声明与该namespace完全一致,避免因包名不匹配导致类无法被正确识别。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.24 19:41:28