Type com.nikolam.nsdkelper.BuildConfig is defined multiple times: /storage/Users/Volks/Desktop/Android-2020/NsdKelper/app/build/intermediates/project_dex_archive/release/out/com/nikolam/nsdkelper/BuildConfig.dex, /storage/Users/Volks/Desktop/Android-2020/NsdKelper/nsdkelper/build/.transforms/6fff326acaa87110e65737aff5d0e0cd/classes/classes.dex
./gradlew test build
输出这个
我有一个实现我的 LibraryModule 的应用程序模块,仅此而已
这些是推荐的修复
This error typically occurs due to one of the following circumstances:
A binary dependency includes a library that your app also includes as a direct dependency. For example, your app declares a direct dependency on Library A and Library B, but Library A already includes Library B in its binary.
To resolve this issue, remove Library B as a direct dependency.
Your app has a local binary dependency and a remote binary dependency on the same library.
To resolve this issue, remove one of the binary dependencies.
这些是库和应用程序的两个构建 gradle 的依赖项。
dependencies {
///LIBRARY
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.3.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
///APP
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(":nsdkelper")
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
应用整个 build.gradle https://hastebin.com/dehedobica.php
图书馆整个 build.gradle https://hastebin.com/omahuqutuc.nginx
我可以删除直接依赖项并使用 JITPACK.io,但我想将其保留在本地以进行开发,我尝试更新依赖项、gradle 版本和降级版本,但似乎没有任何效果。我还删除了一些依赖项,但这也无济于事。我使缓存和类似的常见修复程序无效,但没有成功。
我尝试从 App 模块中删除依赖项并仅实现 Library(NsdKelper),但它并不像我认为的那样工作。我的思路是
A 实现项目 B,这意味着 A 将检查 B 的依赖项并使用它们。但这里似乎并非如此。从我的应用程序模块中删除依赖项会导致我出现缺少库的错误。或者我是不是误会了什么
最佳答案
他们有相同的包 ID,重命名其中一个模块上的包解决了这个问题。
关于android - 多次定义BuildConfig,Gradle Test Build报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62972135/