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

集成特定库后Gradle构建报错:Program type already present异常

Hey there, let's fix that frustrating Gradle build error you're dealing with! That "Program type already present" message tells us your project has duplicate copies of the same class—in this case, com.nostra13.universalimageloader.cache.disc.impl.ext.DiskLruCache$1 from Universal Image Loader (UIL). Here's how to resolve it step by step:

1. Find where the duplicate dependency is coming from

First, we need to pinpoint which library is bringing in an extra copy of UIL. Run this command in your project root (or use Android Studio's built-in Gradle tooling):

./gradlew app:dependencies

Or in Android Studio:

  • Open the Gradle sidebar (usually on the right-hand side)
  • Navigate to your app module > Tasks > android > androidDependencies
  • Run that task, then search the output for "universal-image-loader"

You’ll see two entries for UIL: one you added explicitly, and another from a third-party library—that’s the duplicate causing the conflict.

2. Exclude the duplicate UIL from the conflicting library

Once you’ve identified the problematic library, add an exclusion rule to your module-level build.gradle file. For example, if the conflicting library is com.example.thirdparty:somelib:2.0.0, update its dependency entry like this:

implementation('com.example.thirdparty:somelib:2.0.0') {
    exclude group: 'com.nostra13.universalimageloader', module: 'universal-image-loader'
}

This tells Gradle to keep only the UIL version you explicitly added, discarding the duplicate copy from the third-party library.

3. Double-check your own dependency declarations

It’s also possible you accidentally added UIL multiple times in your dependencies block. Scan for lines like:

implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'

Make sure there’s only one entry for UIL, and use the latest stable version if possible.

4. Clean and rebuild to clear stale cache

After adjusting your dependencies, don’t skip this critical step—old build cache can still cause conflicts:

  • Go to Build > Clean Project in Android Studio
  • Then run Build > Rebuild Project

This ensures Gradle uses your updated dependency configuration instead of cached files.

Bonus: Consider switching to a modern image loader

Universal Image Loader is no longer actively maintained. If you want to avoid these kinds of dependency conflicts long-term, switching to libraries like Glide or Picasso is a smart move—they’re faster, better supported, and less likely to clash with other project dependencies.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 07:35:54