You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

IntelliJ IDEA中LibGDX项目运行失败的配置指导求助

Hey there! As a fellow LibGDX beginner who’s been through this exact headache, let’s walk through fixing that exit value 1 error step by step. It’s almost always a small config tweak that’s causing the issue—here’s what to check:

1. Verify JDK Compatibility & Gradle JVM Setup

LibGDX versions and JDKs need to play nice together, and this is the most common culprit:

  • First, check your LibGDX version in the root build.gradle file (look for the gdxVersion line). If it’s older than 1.12.0, it might not fully support JDK 17. Update it to the latest stable version if needed.
  • In IntelliJ, go to File > Settings > Build, Execution, Deployment > Build Tools > Gradle and make sure the "Gradle JVM" matches the JDK you’re using (JDK 11 or 17 works best with modern LibGDX).
2. Double-Check the Desktop Module Config

The desktop launcher is often where things go awry for new users:

  • Open the desktop module’s build.gradle and confirm these lines match your JDK version:
    sourceCompatibility = 17
    targetCompatibility = 17
    
  • Make sure your DesktopLauncher class hasn’t been accidentally modified. It should look something like this (replace MyGdxGame with your actual game main class):
    public class DesktopLauncher {
        public static void main(String[] arg) {
            LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
            new LwjglApplication(new MyGdxGame(), config);
        }
    }
    
    Missing or incorrect code here will immediately throw an exit value 1 error.
3. Clean & Rebuild to Clear Cache Issues

Stale build cache can cause weird, unexplained errors—let’s wipe it out:

  • In IntelliJ, click File > Invalidate Caches... and select "Invalidate and Restart" to clear IDE-level cache.
  • Open the Gradle panel (right sidebar), expand your project, then run Tasks > build > clean followed by Tasks > build > build to rebuild everything from scratch.
  • For more detailed error logs, try running the project via the command line instead of IntelliJ:
    • On Windows: Open a terminal in your project root, run gradlew.bat desktop:run
    • On Mac/Linux: Run ./gradlew desktop:run
      This will show you the full stack trace, which is way more helpful than the truncated IntelliJ console output.
4. Update LWJGL Dependencies

Older LWJGL versions (the library that powers LibGDX’s desktop backend) can clash with JDK 17. In your root build.gradle, make sure the lwjglVersion is set to a modern version (matching your LibGDX version—for LibGDX 1.12.0+, use 3.3.2):

lwjglVersion = "3.3.2"

If none of these steps fix the issue, run gradlew desktop:run --stacktrace (or gradlew.bat desktop:run --stacktrace on Windows) and share the full stack trace—this will let us pinpoint exactly what’s breaking.

内容的提问来源于stack exchange,提问作者Jamal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 20:02:28