com.android.dex.DexException: Multiple dex files define Lcom/handmark/pulltorefresh/library/BuildConfig;
Execution failed for task ':centralAsia:dexDebug'.
同一庫 pulltorefresh 以兩種形式被引入:
:pullToRefresh_librarylibs/ 或 Maven 依賴編譯時生成兩份 BuildConfig.class,DEX 合併衝突。
// build.gradle (app/module)
dependencies {
implementation project(':pullToRefresh_library')
// 刪除這行:implementation files('libs/pulltorefresh.jar')
// 或刪除:implementation 'com.handmark:pulltorefresh:xxx'
}
// build.gradle
android {
defaultConfig {
multiDexEnabled true
}
}
dependencies {
implementation 'androidx.multidex:multidex:2.0.1'
}
// Application 類
public class MyApp extends MultiDexApplication { }
android {
packagingOptions {
exclude 'com/handmark/pulltorefresh/library/BuildConfig.class'
}
}
compileSdkVersion / targetSdkVersion 與支持庫版本匹配