每个人!我正在尝试将依赖项添加到build.gradle 中的 gdx-pd,但是当我尝试同步项目时,我收到此错误:
原因:groovy.lang.MissingPropertyException:无法为 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler 类型的对象获取未知属性“pdVersion”。
这是我的 Gradle 文件的样子:
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
}
}
所有项目{
version = '1.0'
ext {
appName = "audio-demo"
gdxVersion = '1.9.10'
roboVMVersion = '2.3.7'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
google()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
项目(“:桌面”){应用插件:“java-library”
dependencies {
implementation project(":core")
api "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
api "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
api "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
api "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
api "net.mgsx.gdx:gdx-pd-platform:$pdVersion:desktop"
api "net.mgsx.gdx:gdx-pd-platform:$pdVersion:natives-desktop"
}
}
项目(“:android”){应用插件:“android”
configurations { natives }
dependencies {
implementation project(":core")
api "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"
api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
api "net.mgsx.gdx:gdx-pd-backend-android:$pdVersion"
natives "net.mgsx.gdx:gdx-pd-platform:$pdVersion:natives-armeabi"
natives "net.mgsx.gdx:gdx-pd-platform:$pdVersion:natives-armeabi-v7a"
natives "net.mgsx.gdx:gdx-pd-platform:$pdVersion:natives-arm64-v8a"
natives "net.mgsx.gdx:gdx-pd-platform:$pdVersion:natives-x86"
natives "net.mgsx.gdx:gdx-pd-platform:$pdVersion:natives-x86_64"
}
}
项目(“:核心”){应用插件:“java-library”
dependencies {
api "com.badlogicgames.gdx:gdx:$gdxVersion"
api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
api "net.mgsx.gdx:gdx-pd:$pdVersion"
}
}
如果我尝试像这样指定 $pdVersion:
ext {
...
pdVersion = '0.7.0'
}
我收到另一个错误:
错误:无法解决:net.mgsx.gdx:gdx-pd:0.7.0 在项目结构对话框中显示受影响的模块:核心错误:无法解决:net.mgsx.gdx:gdx-pd:0.7.0 在项目中显示结构对话框 受影响的模块:android
我究竟做错了什么?先感谢您!