gpt4 book ai didi

java - 无法在 Netbeans 上编译 libGDX

转载 作者:太空宇宙 更新时间:2023-11-04 12:33:46 24 4
gpt4 key购买 nike

我正在尝试使用 Netbeans 建立一个简单的 libGDX 项目。不幸的是,我的编译器似乎找不到任何要链接的 libGDX jar。 Gradle 不是应该自动为您查找并安装所有依赖项吗?无论如何,当我尝试“运行”桌面项目时,编译器会给出以下信息:

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 的“依赖”子句完全是空的。我将它们重写为看起来像

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 中。

关于java - 无法在 Netbeans 上编译 libGDX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37559576/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com