[英]how to add a library to the dependencies gradle of LIBGDX project
All is in the question , I've tried all the answers I found in SO and others sites but with no luck , this is what I've tried so far : 全部都在问题中,我已经尝试了在SO和其他网站上找到的所有答案,但是没有运气,这是我到目前为止已经尝试的:
adding compile fileTree(dir: 'lib', include: '*.jar')
to my build.gradle 将
compile fileTree(dir: 'lib', include: '*.jar')
到我的build.gradle
adding compile files('lib/tween-engine-api-sources.jar')
to build.gradle 添加
compile files('lib/tween-engine-api-sources.jar')
到build.gradle
the library I want to add is Tween engine . 我要添加的库是Tween引擎 。
build.gradle file : build.gradle文件:
buildscript {
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = 'my-gdx-game'
gdxVersion = '1.5.4'
roboVMVersion = '1.0.0-SNAPSHOT'
box2DLightsVersion = '1.3'
ashleyVersion = '1.3.1'
aiVersion = '1.5.0'
}
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-controllers-desktop:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-controllers-platform:$gdxVersion:natives-desktop"
}
}
project(":core") {
apply plugin: "java"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-ai:$aiVersion"
compile "com.badlogicgames.ashley:ashley:$ashleyVersion"
compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
compile fileTree(dir: 'lib', include: '*.jar')
}
}
tasks.eclipse.doLast {
delete ".project"
}
In the wiki article Dependency management with Gradle , you can find all the information you need. 在Wiki文章Gradient中的Dependency management中 ,您可以找到所需的所有信息。 There's even an extra part about the Tween Engine.
关于Tween引擎,甚至还有其他内容。
Your approach should work, however, you need to update Eclipse via a Right-Click on your projects -> Gradle -> Refresh Dependencies
. 您的方法应该可行,但是,您需要通过
Right-Click on your projects -> Gradle -> Refresh Dependencies
来更新Eclipse。
For me it worked better though to install the dependencies in my local repository and then reference it from there, instead of referencing the lib folder. 对我来说,最好将其安装在本地存储库中,然后从那里引用它,而不是引用lib文件夹。 This is described here .
这在这里描述。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.