【问题标题】:LibGDX - Android Studio cannot resolve symbolLibGDX - Android Studio 无法解析符号
【发布时间】:2026-02-01 19:45:01
【问题描述】:

我们必须创建一个 android 应用程序并且我们想要为 3d 模型制作动画。 因此,我们想使用 libgdx。所以我们将这些行添加到我们在 android studio 中的 build.gradle 文件中:

ext {
    appName = 'bream'
    gdxVersion = '1.3.1'
}

repositories {
    mavenCentral()
    mavenLocal()
    maven { url "https://jitpack.io" }
    maven { url 'https://github.com/steffenschaefer/gwt-gradle-plugin/raw/maven-repo/' }
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}

dependencies {
    compile 'com.facebook.android:facebook-android-sdk:3.23.0'
    compile 'com.android.support:support-v4:23.0.0'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.github.PhilJay:MPAndroidChart:v2.1.6'
    compile "com.badlogicgames.gdx:gdx:$gdxVersion"
}

但是,它没有找到“com.badlogic.gdx.backends.android”和此导入附带的 AndroidApplication 类。有谁知道如何解决这个问题?

提前致谢!

【问题讨论】:

    标签: android libgdx symbols resolve


    【解决方案1】:

    因为您显然没有加载“com.badlogic.gdx.backends.android”。您只加载核心 LibGDX。这是 Android gradle 构建的样子。

            compile "com.badlogicgames.gdx:gdx:$gdxVersion"  // core        
            compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
            natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
            natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
            natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
            natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
            natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
    

    我建议您从他们的网站下载 LibGDX 的 gradle setup 应用程序,以了解依赖项如何协同工作。

    【讨论】: