在Android Studio Project中的APK README.md中复制的重复文件

时间:2016-11-29 09:53:58

标签: java android android-studio selendroid

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

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')
}

2 个答案:

答案 0 :(得分:1)

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

即可
 packagingOptions {
exclude 'META-INF/README'}

packagingOptions {
exclude 'README'}

尝试以上两个选项。

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

答案 1 :(得分:0)

在应用级抓点文件中写下以下行

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

在此处找到this answer