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

使用libgdx与gdx-sqlite调试游戏时出现Program type already present错误

Fixing "Program type already present: com.badlogic.gdx.sql.Database" in libGDX

Hey, I’ve dealt with this exact duplicate class error when working with libGDX and gdx-sqlite—here’s how to troubleshoot and fix it step by step:

  • Check for duplicate dependencies
    First, dig into your project’s build.gradle files (both the Android module and core module). Look for any repeated references to gdx-sqlite: this could mean you’ve added both a local JAR file (from your GitHub download) and a Maven/Gradle dependency entry for the same library. Pick one method (either local JAR or remote dependency) and remove the other.

  • Clean project caches
    Android Studio’s cached build files often cause weird duplicate class issues. Do two things:

    1. Run ./gradlew clean (use gradlew clean on Windows) in your project root to wipe build artifacts.
    2. Go to File > Invalidate Caches... > Invalidate and Restart to clear Studio’s internal cache.
  • Audit your dependency tree
    Sometimes other libGDX extensions might pull in gdx-sql related classes indirectly. Run ./gradlew [your-android-module-name]:dependencies (replace [your-android-module-name] with something like android) to generate a full dependency tree. Look for multiple entries of com.badlogic.gdx:gdx-sql or similar. If you find duplicates, add an exclude rule to your dependency to remove the redundant one. For example:

    implementation 'com.example.somelibrary:somelib:1.0' {
        exclude group: 'com.badlogic.gdx', module: 'gdx-sql'
    }
    
  • Verify local library setup
    If you’re using the manually downloaded gdx-sqlite library, double-check that you haven’t accidentally added it to multiple modules (like core and Android). The gdx-sqlite setup usually requires adding the core library to your core module and the platform-specific library to your Android module—no duplicates here.

  • Resync your project
    After making any changes to build files, click the "Sync Project with Gradle Files" button (the elephant icon) in the top-right corner of Android Studio to ensure all changes are applied.

This error almost always boils down to the same class being included in your build multiple times—so focusing on eliminating those duplicates should get your game running again.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.26 08:18:43