Java Can';在Netbeans上编译libGDX
我正在尝试使用Netbeans建立一个简单的libGDX项目。不幸的是,我的编译器似乎找不到任何要链接的libGDX jar。Gradle不是应该自动为您查找并安装所有依赖项吗?在任何情况下,当我尝试“运行”桌面项目时,编译器都会给出以下信息:Java Can';在Netbeans上编译libGDX,java,android,netbeans,gradle,libgdx,Java,Android,Netbeans,Gradle,Libgdx,我正在尝试使用Netbeans建立一个简单的libGDX项目。不幸的是,我的编译器似乎找不到任何要链接的libGDX jar。Gradle不是应该自动为您查找并安装所有依赖项吗?在任何情况下,当我尝试“运行”桌面项目时,编译器都会给出以下信息: Executing: gradle run Arguments: [-c, C:\dev\starling2\game\2016\fightland\libgdx\settings.gradle] Configuration on demand is
Executing: gradle run
Arguments: [-c, C:\dev\starling2\game\2016\fightland\libgdx\settings.gradle]
Configuration on demand is an incubating feature.
warning: [options] bootstrap class path not set in conjunction with -source 1.6
C:\dev\starling2\game\2016\fightland\libgdx\core\src\com\kitfox\fightland\FightlandGdxGame.java:3: error: package com.badlogic.gdx does not exist
import com.badlogic.gdx.ApplicationAdapter;
^
C:\dev\starling2\game\2016\fightland\libgdx\core\src\com\kitfox\fightland\FightlandGdxGame.java:4: error: package com.badlogic.gdx does not exist
import com.badlogic.gdx.Gdx;
^
C:\dev\starling2\game\2016\fightland\libgdx\core\src\com\kitfox\fightland\FightlandGdxGame.java:5: error: package com.badlogic.gdx.graphics does not exist
import com.badlogic.gdx.graphics.GL20;
^
C:\dev\starling2\game\2016\fightland\libgdx\core\src\com\kitfox\fightland\FightlandGdxGame.java:6: error: package com.badlogic.gdx.graphics does not exist
import com.badlogic.gdx.graphics.Texture;
^
C:\dev\starling2\game\2016\fightland\libgdx\core\src\com\kitfox\fightland\FightlandGdxGame.java:7: error: package com.badlogic.gdx.graphics.g2d does not exist
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
^
C:\dev\starling2\game\2016\fightland\libgdx\core\src\com\kitfox\fightland\FightlandGdxGame.java:9: error: cannot find symbol
public class FightlandGdxGame extends ApplicationAdapter {
^
symbol: class ApplicationAdapter
C:\dev\starling2\game\2016\fightland\libgdx\core\src\com\kitfox\fightland\FightlandGdxGame.java:10: error: cannot find symbol
SpriteBatch batch;
^
symbol: class SpriteBatch
location: class FightlandGdxGame
C:\dev\starling2\game\2016\fightland\libgdx\core\src\com\kitfox\fightland\FightlandGdxGame.java:11: error: cannot find symbol
Texture img;
^
symbol: class Texture
location: class FightlandGdxGame
C:\dev\starling2\game\2016\fightland\libgdx\core\src\com\kitfox\fightland\FightlandGdxGame.java:13: error: method does not override or implement a method from a supertype
@Override
^
C:\dev\starling2\game\2016\fightland\libgdx\core\src\com\kitfox\fightland\FightlandGdxGame.java:15: error: cannot find symbol
batch = new SpriteBatch();
^
symbol: class SpriteBatch
location: class FightlandGdxGame
C:\dev\starling2\game\2016\fightland\libgdx\core\src\com\kitfox\fightland\FightlandGdxGame.java:16: error: cannot find symbol
img = new Texture("badlogic.jpg");
^
symbol: class Texture
location: class FightlandGdxGame
C:\dev\starling2\game\2016\fightland\libgdx\core\src\com\kitfox\fightland\FightlandGdxGame.java:19: error: method does not override or implement a method from a supertype
@Override
^
C:\dev\starling2\game\2016\fightland\libgdx\core\src\com\kitfox\fightland\FightlandGdxGame.java:21: error: package Gdx does not exist
Gdx.gl.glClearColor(1, 0, 0, 1);
^
C:\dev\starling2\game\2016\fightland\libgdx\core\src\com\kitfox\fightland\FightlandGdxGame.java:22: error: cannot find symbol
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
^
symbol: variable GL20
location: class FightlandGdxGame
C:\dev\starling2\game\2016\fightland\libgdx\core\src\com\kitfox\fightland\FightlandGdxGame.java:22: error: package Gdx does not exist
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
^
15 errors
1 warning
:core:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':core:compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 2.246 secs
Build failure (see the Notifications window for stacktrace): gradle run
这是刚从libGDX项目设置实用程序生成的代码。我没有做任何改变。我尝试将根项目中的源代码级别更改为1.6,但没有帮助
我读过的另一篇文章建议将libGDX jar放在我的类路径上,但我不确定这些jar是什么,也不知道在哪里可以找到它们
我记得大约一年半前这样做,没有遇到任何问题。我不确定我做错了什么
因此,我能够通过使用由早期版本的安装插件生成的libGDX项目中的代码修补build.gradle文件,从而在一定程度上解决了我的问题。基本上,最新版本的gdx-setup.jar生成的build.gradle具有完全为空的“dependency”子句。我把它们改写成
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-bullet-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":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-x86"
compile "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86"
compile "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-x86"
compile "com.badlogicgames.gdx:gdx-ai:$aiVersion"
}
}
project(":ios") {
apply plugin: "java"
apply plugin: "robovm"
dependencies {
compile project(":core")
compile "org.robovm:robovm-rt:$roboVMVersion"
compile "org.robovm:robovm-cocoatouch:$roboVMVersion"
compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
compile "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-ios"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
}
}
project(":html") {
apply plugin: "gwt"
apply plugin: "war"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
compile "com.badlogicgames.gdx:gdx-ai:$aiVersion:sources"
}
}
project(":core") {
apply plugin: "java"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-ai:$aiVersion"
}
}
现在,桌面项目将编译并运行。还没试过安卓。ios项目向我发送了关于“依赖项解析失败”的错误消息,我不知道如何修复该错误。我有点好奇为什么安装工具没有生成任何依赖信息
我刚刚尝试用最新版本的安装插件再次生成项目,这次成功了。不知道为什么我的依赖项第一次都是空的。我也有同样的问题 尝试在我的计算机上添加第三方扩展时,libgdx安装程序导致运行时异常。异常发生后,通常显示的一个生成器对话框未能显示
- 我在没有添加任何第三方扩展的情况下生成了一个新项目,并且我获得了一个成功的项目,现在可以很好地导入eclipse
- 我在没有添加任何第三方扩展的情况下生成了一个新项目,并且我获得了一个成功的项目,现在可以很好地导入eclipse
- 我也有同样的问题
尝试在我的计算机上添加第三方扩展时,libgdx安装程序导致运行时异常。异常发生后,通常显示的一个生成器对话框未能显示