gpt4 book ai didi

安卓 gradle 构建 : duplicate files during packaging of APK LICENSE. txt

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:13:37 38 4
gpt4 key购买 nike

我正在尝试使用以下 gradle 构建文件构建 Android 测试

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.2'
}

apply plugin: 'android-library'

repositories {
mavenCentral()
}

dependencies {
instrumentTestCompile "junit:junit:4.+"
}

android {
compileSdkVersion 17
buildToolsVersion "17.0.0"

instrumentTest.setRoot('tests')
instrumentTest {
java.srcDirs = ['tests/src']
res.srcDirs = ['tests/res']
assets.srcDirs = ['tests/assets']
resources.srcDirs = ['tests/src']
}
}
}

运行时出现以下错误:

Error: duplicate files during packaging of APK ... Path in archive: LICENSE.txt Origin 1: ....gradle/caches/artifacts-24/filestore/junit/junit/4.11/jar/4e031bb61df09069aeb2bffb4019e7a5034a4ee0/junit-4.11.jar Origin 2: ....gradle/caches/artifacts-24/filestore/org.hamcrest/hamcrest-core/1.3/jar/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar :packageTest FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':packageTest'. Duplicate files at the same path inside the APK: LICENSE.txt

最佳答案

Junit v4.5 已将所有必需的依赖项打包到 JUnit jar 中。因此不需要 hamcrest.jar,也不会产生双重 LICENSE.txt 文件。

只需将依赖项更改为:

instrumentTestCompile "junit:junit:4.5+"

基本问题仍然存在 - android 不接受在其构建树中具有相同名称的两个文件。不过,这是一个很好的解决方法。

关于安卓 gradle 构建 : duplicate files during packaging of APK LICENSE. txt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17924608/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com