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

By : tad

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. 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: ''

buildscript {
    repositories {
    dependencies {
        classpath ''

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'), ''
    productFlavors {

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile ''
    compile ''
    compile ('io.appium:java-client:4.1.2'){

By : tad

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