I am having the troubles with the Appium java client, I tried to restart Android Studio, do something with some solution in google search but i still can't fix them.
public class MainActivity extends AppCompatActivity {
public static void openCaculator() throws MalformedURLException {
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("deviceName","Redmi 7A");
cap.setCapability("udid","c63309269906");
cap.setCapability("platformName","android");
cap.setCapability("platformVersion","9");
cap.setCapability("appPakage","com.miui.calculator");
cap.setCapability("appActivity",".cal.CalculatorActivity");
URL url = new URL("http://127.0.0.1:4723/wd/hub");
appiumDriver = new AppiumDriver<MobileElement>(cap);
System.out.println("Application Started");
}
}
This is my gradle:
apply plugin: 'com.android.application'
android {
dependencies {
// https://mvnrepository.com/artifact/io.appium/java-client
implementation group: 'io.appium', name: 'java-client', version: '7.3.0'
// https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java
implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.59'
}
And this is my result when built:
Duplicate class org.apache.commons.logging.Log found in modules jetified-commons-logging-1.2.jar (commons-logging:commons-logging:1.2) and jetified-spring-jcl-5.1.8.RELEASE.jar (org.springframework:spring-jcl:5.1.8.RELEASE)
Duplicate class org.apache.commons.logging.LogFactory found in modules jetified-commons-logging-1.2.jar (commons-logging:commons-logging:1.2) and jetified-spring-jcl-5.1.8.RELEASE.jar (org.springframework:spring-jcl:5.1.8.RELEASE)
Duplicate class org.apache.commons.logging.LogFactory$1 found in modules jetified-commons-logging-1.2.jar (commons-logging:commons-logging:1.2) and jetified-spring-jcl-5.1.8.RELEASE.jar (org.springframework:spring-jcl:5.1.8.RELEASE)
Duplicate class org.apache.commons.logging.impl.NoOpLog found in modules jetified-commons-logging-1.2.jar (commons-logging:commons-logging:1.2) and jetified-spring-jcl-5.1.8.RELEASE.jar (org.springframework:spring-jcl:5.1.8.RELEASE)
Duplicate class org.apache.commons.logging.impl.SimpleLog found in modules jetified-commons-logging-1.2.jar (commons-logging:commons-logging:1.2) and jetified-spring-jcl-5.1.8.RELEASE.jar (org.springframework:spring-jcl:5.1.8.RELEASE)
Duplicate class org.openqa.selenium.SearchContext found in modules jetified-java-client-7.3.0.jar (io.appium:java-client:7.3.0) and jetified-selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59)
Duplicate class org.openqa.selenium.WebDriver found in modules jetified-java-client-7.3.0.jar (io.appium:java-client:7.3.0) and jetified-selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59)
Duplicate class org.openqa.selenium.WebDriver$ImeHandler found in modules jetified-java-client-7.3.0.jar (io.appium:java-client:7.3.0) and jetified-selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59)
Duplicate class org.openqa.selenium.WebDriver$Navigation found in modules jetified-java-client-7.3.0.jar (io.appium:java-client:7.3.0) and jetified-selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59)
Duplicate class org.openqa.selenium.WebDriver$Options found in modules jetified-java-client-7.3.0.jar (io.appium:java-client:7.3.0) and jetified-selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59)
Duplicate class org.openqa.selenium.WebDriver$TargetLocator found in modules jetified-java-client-7.3.0.jar (io.appium:java-client:7.3.0) and jetified-selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59)
Duplicate class org.openqa.selenium.WebDriver$Timeouts found in modules jetified-java-client-7.3.0.jar (io.appium:java-client:7.3.0) and jetified-selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59)
Duplicate class org.openqa.selenium.WebDriver$Window found in modules jetified-java-client-7.3.0.jar (io.appium:java-client:7.3.0) and jetified-selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59)
Duplicate class org.openqa.selenium.WebElement found in modules jetified-java-client-7.3.0.jar (io.appium:java-client:7.3.0) and jetified-selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59)
Duplicate class org.openqa.selenium.internal.FindsByClassName found in modules jetified-java-client-7.3.0.jar (io.appium:java-client:7.3.0) and jetified-selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59)
Duplicate class org.openqa.selenium.internal.FindsByCssSelector found in modules jetified-java-client-7.3.0.jar (io.appium:java-client:7.3.0) and jetified-selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59)
Duplicate class org.openqa.selenium.internal.FindsById found in modules jetified-java-client-7.3.0.jar (io.appium:java-client:7.3.0) and jetified-selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59)
Duplicate class org.openqa.selenium.internal.FindsByLinkText found in modules jetified-java-client-7.3.0.jar (io.appium:java-client:7.3.0) and jetified-selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59)
Duplicate class org.openqa.selenium.internal.FindsByName found in modules jetified-java-client-7.3.0.jar (io.appium:java-client:7.3.0) and jetified-selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59)
Duplicate class org.openqa.selenium.internal.FindsByTagName found in modules jetified-java-client-7.3.0.jar (io.appium:java-client:7.3.0) and jetified-selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59)
Duplicate class org.openqa.selenium.internal.FindsByXPath found in modules jetified-java-client-7.3.0.jar (io.appium:java-client:7.3.0) and jetified-selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59)
I hope someone help me! Thank you!!!
I came cross the same exact issue and I was able to resolve the dependencies duplication by excluding selenium-api from io.appium:java-client and defined selenium-java as compileOnly scope. Here is my build.gradle deps
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'log4j:log4j:1.2.17'
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
compileOnly ('org.seleniumhq.selenium:selenium-java:3.141.59')
implementation ('io.appium:java-client:7.3.0') {
['org.apache.commons','commons-logging',
'junit'].each {
exclude group: "$it"
}
exclude group: "org.seleniumhq.selenium", module: "selenium-api"
}
implementation ('junit:junit:4.13') {
['org.hamcrest'].each {
exclude group: "$it"
}
}
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
try this:
testImplementation (group: 'io.appium', name: 'java-client', version: '7.3.0')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With