Getting a duplicate error when trying to setup android studio with appium FindsByClassName

By : tad
Source: Stackoverflow.com
Question!

I have just started to learn appium using Android Studio.

After following some earlier posts for the build.gradle (app) by setting multiDexEnabled true still get the below error when trying to run a sample program.

Error:Gradle: Execution failed for task :app:transformClassesWithJarMergingForDebug.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/openqa/selenium/internal/FindsByClassName.class

I understand with previous posts that there is a duplicate entry but when I try doing an exclude for the compile ('io.appium:java-client:4.1.2') an error shows up when the build.gradle is getting synced.Hence I had to include the org/openqa/selenium/internal/ folder.

The commands ./gradlew clean and ./gradlew dependencies were also tried in terminal.It printed out all the dependencies but I am lost on how to identify the duplicate.

Please find below my module build.gradle

    apply plugin: 'com.android.application'


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

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"
    defaultConfig {
        applicationId "com.example.helloworld"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.android.support:design:24.2.0'
    compile ('io.appium:java-client:4.1.2'){

    }
}
By : tad


Answers
If you have jar file in your lib folder just remove and compile your dependency then you will be fine .

By : Surace


This video can help you solving your question :)
By: admin