-1

im trying to run this test in Android Studio using 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();
    }
}

}

I have added the needed libraries (selendroid-client-0.17.0.jar and selendroid-standalone-0.17.0-with-dependencies.jar) before running and I have started the server thru the cmd. However, I get this error everytime I run it:

    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

I have not really found any suggestions online on how to fix it. I hope you guys can help out. Thanks!

EDIT: Here is my build.gradle file:

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')
}
  • 1
    *I have not really found any suggestions online on how to fix it.* ... becuase you didn't even tried ... I found it with one simple google query ... and no, I will not provide answer as SO is not human search engine – Selvin Nov 29 '16 at 09:56
  • i have tried a lot already but unfortunately, it creates other errors. Thanks for the tip though. – user2953186 Nov 29 '16 at 10:10
  • Note that your duplicate file is not in META-INF folder. `exclude 'README'` should fix it – Benito Bertoli Nov 29 '16 at 10:21

2 Answers2

1

Just add this to your build.gradle file

 packagingOptions {
exclude 'META-INF/README'}

packagingOptions {
exclude 'README'}

Try with above two options.

Please do some research before posting any question here. You can easily get answers for such questions on google.

Prashant Sable
  • 1,003
  • 7
  • 19
0

Write below lines in your app level gradle file

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

Found here Android Gradle Duplicate files copied in APK META-INF/license.txt

Community
  • 1
  • 1
Mahesh Babariya
  • 4,560
  • 6
  • 39
  • 54