appium / java-client

Java language binding for writing Appium Tests, conforms to W3C WebDriver Protocol
Apache License 2.0
1.18k stars 751 forks source link

Android studio can't build #1258

Open pxr89 opened 4 years ago

pxr89 commented 4 years ago

Duplicate class org.openqa.selenium.SearchContext found in modules java-client-7.2.0.jar (com.github.appium:java-client:7.2.0) and selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59) Duplicate class org.openqa.selenium.WebDriver found in modules java-client-7.2.0.jar (com.github.appium:java-client:7.2.0) and selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59) Duplicate class org.openqa.selenium.WebDriver$ImeHandler found in modules java-client-7.2.0.jar (com.github.appium:java-client:7.2.0) and selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59) Duplicate class org.openqa.selenium.WebDriver$Navigation found in modules java-client-7.2.0.jar (com.github.appium:java-client:7.2.0) and selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59) Duplicate class org.openqa.selenium.WebDriver$Options found in modules java-client-7.2.0.jar (com.github.appium:java-client:7.2.0) and selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59) Duplicate class org.openqa.selenium.WebDriver$TargetLocator found in modules java-client-7.2.0.jar (com.github.appium:java-client:7.2.0) and selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59) Duplicate class org.openqa.selenium.WebDriver$Timeouts found in modules java-client-7.2.0.jar (com.github.appium:java-client:7.2.0) and selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59) Duplicate class org.openqa.selenium.WebDriver$Window found in modules java-client-7.2.0.jar (com.github.appium:java-client:7.2.0) and selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59) Duplicate class org.openqa.selenium.WebElement found in modules java-client-7.2.0.jar (com.github.appium:java-client:7.2.0) and selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59) Duplicate class org.openqa.selenium.internal.FindsByClassName found in modules java-client-7.2.0.jar (com.github.appium:java-client:7.2.0) and selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59) Duplicate class org.openqa.selenium.internal.FindsByCssSelector found in modules java-client-7.2.0.jar (com.github.appium:java-client:7.2.0) and selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59) Duplicate class org.openqa.selenium.internal.FindsById found in modules java-client-7.2.0.jar (com.github.appium:java-client:7.2.0) and selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59) Duplicate class org.openqa.selenium.internal.FindsByLinkText found in modules java-client-7.2.0.jar (com.github.appium:java-client:7.2.0) and selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59) Duplicate class org.openqa.selenium.internal.FindsByName found in modules java-client-7.2.0.jar (com.github.appium:java-client:7.2.0) and selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59) Duplicate class org.openqa.selenium.internal.FindsByTagName found in modules java-client-7.2.0.jar (com.github.appium:java-client:7.2.0) and selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59) Duplicate class org.openqa.selenium.internal.FindsByXPath found in modules java-client-7.2.0.jar (com.github.appium:java-client:7.2.0) and selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59)

pxr89 commented 4 years ago

gradle config:

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.cmcm.vase.appium"
        minSdkVersion 24
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation 'com.github.appium:java-client:7.2.0'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
}
pxr89 commented 4 years ago

anyone has some idea?

ebycloudins commented 4 years ago

I got the same issue. Didn't find any solution yet

abhishekgargx commented 4 years ago

i have faced similar issue with Android studio, and even speak with maintainer (Srinivasan) of this library. and found out they do not use android studio or intelli j to test or build this library. so to use this library i made a seperate branch which contains test cases only and sync the gradle only as build is always failed, i even tired excluding some of internal dependencies of this libraries to resolve the conflict but some of selinium and other library are tightly coupled and i guess are base of this library. hence to

fix this issue only sync gradle , --> then start appium server --> then run script directly on terminal

. it worked. also currently using 7.2.0 version as there are some issues are live on 7.3.0 .

zsamora commented 4 years ago

@Abhishekgarg727 when you say run script directly on terminal, you mean building the APK and the executing on the device? because it doesn't work either

TheOnlyRoshan commented 3 years ago

@pxr89 @zsamora @ebycloudins @Abhishekgarg727 @jarib found the solution here - https://www.youtube.com/watch?v=sAWDy3UHSZY

PawandeepKaur2405 commented 3 years ago

@pxr89 Is the issue resolved?

HaxThePlanet commented 3 years ago

This fixed "Duplicate class org.openqa.selenium.SearchContext" for me:

TLDR: open java-client jar, remove those classes.

https://www.youtube.com/watch?v=sAWDy3UHSZY