【问题标题】:Duplicate files copied in APK README.md in Android Studio Project [duplicate]在 Android Studio 项目中的 APK README.md 中复制的重复文件 [重复]
【发布时间】:2017-04-13 06:18:51
【问题描述】:

我正在尝试使用 selendroid 在 Android Studio 中运行此测试:

public class test_three {

SelendroidLauncher selendroidServer;
WebDriver driver;

public void startServer(){

    SelendroidConfiguration config = new SelendroidConfiguration();
    selendroidServer = new SelendroidLauncher(config);
    selendroidServer.launchSelendroid();

}
@Before
public void beginTest() throws Exception {
    DesiredCapabilities capa = DesiredCapabilities.android();
    capa.setCapability(SelendroidCapabilities.EMULATOR, true);
    driver = new SelendroidDriver(capa);
}

@Test
public void mainTest(){
    driver.get("http://m.ebay.de");
    WebElement element = driver.findElement(By.id("kw"));
    element.sendKeys("Nexus 5");
    element.submit();
}

@After
public void testEnd(){

    if(driver != null){
        driver.quit();
    }
}

}

我在运行之前添加了所需的库(selendroid-client-0.17.0.jar 和 selendroid-standalone-0.17.0-with-dependencies.jar),并通过 cmd 启动了服务器。但是,每次运行时都会出现此错误:

    Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK README.md
    File1: C:\Users\Training\AndroidStudioProjects\Sample_Three\app\libs\selendroid-client-0.17.0.jar
    File2: C:\Users\Training\AndroidStudioProjects\Sample_Three\app\libs\selendroid-standalone-0.17.0-with-dependencies.jar

我还没有真正在网上找到任何关于如何修复它的建议。我希望你们能帮忙。谢谢!

编辑:这是我的 build.gradle 文件:

apply plugin: 'com.android.application'

android {

packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'
}

compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
    applicationId "com.example.training.sample_three"
    minSdkVersion 15
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled  true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}


}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',     {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.1'
testCompile 'junit:junit:4.12'
compile files('libs/selendroid-client-0.17.0.jar')
compile files('libs/selendroid-standalone-0.17.0-with-dependencies.jar')
}

【问题讨论】:

  • 我并没有在网上找到任何关于如何修复它的建议。 ...因为你甚至没有尝试过...我通过一个简单的谷歌查询找到了它...不,我不会提供答案,因为 SO 不是人类搜索引擎
  • 我已经尝试了很多,但不幸的是,它会产生其他错误。不过感谢您的提示。
  • 请注意,您的重复文件不在 META-INF 文件夹中。 exclude 'README' 应该修复它

标签: java android android-studio selendroid


【解决方案1】:

只需将其添加到您的 build.gradle 文件中

 packagingOptions {
exclude 'META-INF/README'}

packagingOptions {
exclude 'README'}

尝试以上两个选项。

在此处发布任何问题之前,请先进行一些研究。您可以在 google 上轻松获得此类问题的答案。

【讨论】:

  • 我已经尝试过了,但它不起作用。问题不在 META-INF 中,而在 APK README.md 中,这就是为什么我很难修复它
  • 在此处粘贴您的 build.gradle 文件。这样我们就可以确切地看到那里有什么。
  • README 后面应该跟 .md (README.md)
【解决方案2】:

在您的应用级 gradle 文件中写入以下行

android {
    packagingOptions {
        exclude 'META-INF/README'
    }
}

在这里找到Android Gradle Duplicate files copied in APK META-INF/license.txt

【讨论】:

  • 如果你在评论部分添加链接就会是这样
  • 我已经尝试过了,但它不起作用。问题不在 META-INF 中,而在 APK README.md 中
猜你喜欢
  • 2017-10-24
  • 1970-01-01
  • 1970-01-01
  • 2014-01-16
  • 2015-02-14
  • 1970-01-01
  • 2015-09-07
  • 2017-10-07
相关资源
最近更新 更多