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

项目中多份OS独立路径'builddef.lst'文件冲突问题求助

Fix for "More than one file was found with OS independent path 'builddef.lst'" Error

I totally get how frustrating this error is—you’ve already configured packagingOptions to exclude files under META-INF, but the issue still sticks around because you can’t track down exactly where builddef.lst is hiding. Let’s work through this step by step:

Step 1: Locate the actual path of builddef.lst

First, we need to find out which dependency or module is bringing in duplicate copies of this file. Use these Gradle commands to pinpoint it:

Option 1: Search dependencies via Gradle task

Run this in Android Studio’s Terminal (adjust for Windows if needed):

# For macOS/Linux
./gradlew app:dependencies --configuration compileClasspath | grep -B2 -A2 builddef.lst

# For Windows
gradlew.bat app:dependencies --configuration compileClasspath | findstr /B /A /C:"builddef.lst"

Option 2: Track file during build process

This command will log all references to builddef.lst while building:

# For macOS/Linux
./gradlew clean && ./gradlew app:assembleDebug --info | grep "builddef.lst"

# For Windows
gradlew.bat clean && gradlew.bat app:assembleDebug --info | findstr "builddef.lst"

Quick GUI trick (Android Studio 4.0+)

Double-click Shift to open the global search, type builddef.lst, and check the Include non-project items box. This will show you copies of the file in your dependency libraries.

Step 2: Resolve the duplicate based on your findings

Once you know where the duplicates are coming from, pick the right fix:

Fix 1: Globally exclude builddef.lst

If you don’t want to dig into specific paths, just add a direct exclusion for the file in your packagingOptions—this works regardless of where the file is located:

packagingOptions {
    // Keep your existing exclusions
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/notice.txt'
    ...
    // Add this line to exclude the problematic file
    exclude 'builddef.lst'
}

Fix 2: Exclude duplicate dependencies

If the issue comes from a third-party dependency pulling in duplicate modules containing builddef.lst, exclude the redundant module in your dependencies block:

implementation('com.example:problematic-library:1.2.3') {
    // Replace with the actual group/module causing duplicates
    exclude group: 'com.example', module: 'duplicate-module'
}

Fix 3: Clean up local module duplicates

If builddef.lst exists in multiple places in your own project modules, delete the extra copies or add a packagingOptions exclusion in the specific module’s build.gradle file.

Final step: Clear build cache

After making changes, run this to ensure old cached files don’t interfere:

# For macOS/Linux
./gradlew clean

# For Windows
gradlew.bat clean

Then rebuild your project.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.21 08:34:24