【问题标题】:Trying to add BaseGameUtils to LibGdx project in android studio尝试将 BaseGameUtils 添加到 android studio 中的 LibGdx 项目
【发布时间】:2014-08-22 11:07:06
【问题描述】:

所以我有一个 LibGdx 游戏,我想在其中添加 Google Play 服务。我正在使用 android studio 但我找不到任何好的教程。

我的游戏根目录中有 BaseGameUtils。我的 settings.gradle 文件看起来像

include 'android', 'ios', 'core', 'BaseGameUtils'

我将 compile project(':BaseGameUtils') 添加到我的 build.gradle 文件的 android 依赖项中,它工作正常,我可以正常使用 android 项目中的类。但是我无法访问核心项目中的类,我想将 GameHandler 传递给游戏,以便我可以使用成就和排行榜。

所以我尝试将同一行添加到 gradle 文件的核心部分,使其看起来像

project(":core") {
apply plugin: "java"


dependencies {
    compile "com.badlogicgames.gdx:gdx:$gdxVersion"
    compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
    compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
    compile fileTree(dir: '../libs', include: '*.jar')
    compile project(':BaseGameUtils')
}
}

但这会导致错误。

Android Studio 给了我这个核心依赖于库但本身不是库错误

【问题讨论】:

    标签: android android-studio libgdx google-play-services


    【解决方案1】:

    您无法在 core 中编译 BaseGameUtils,因为 BaseGameUtils 源需要 Android 库。

    如果您查看这些教程(Fortheloss Games,以及 libGDX Wiki 上提供的其他教程),您必须将 AndroidLauncher 类传递给您的 Game 类。然后,由于除了 Android 之外没有其他平台可以使用 Google 库,因此桌面、HTML 和 iOS 目标将具有实际上不执行任何操作的虚假方法。

    另外,您可能会遇到(或您已经遇到)错误,BaseGameUtils 和 libGDX 的 Android API 版本不同,因此您可能需要进入 BaseGameUtils 并更改其 AndroidManifest.xml 文件。

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-05
      • 1970-01-01
      • 2013-06-15
      • 2018-03-22
      • 2014-04-02
      • 2017-02-02
      相关资源
      最近更新 更多