In our projects we use both selenium & appium java client jars together.
One of the problems I am facing is: duplicate classes
as we are using the same package name: org.openqa.selenium for the classes under the below path in the appium java-client & selenium jars.
https://github.com/appium/java-client/tree/master/src/main/java/org/openqa/selenium
Can we use unique package names please?
We have these classes present both in appium java-client jar & selenium java client jar with the same package name & same class name
WebDriver
WebElement
SearchContext
@vsadineni1 It's not recommended to use both selenium java client and appium java client packages. Appium Java client comes along with selenium java client so there is no necessity to include both. Reason for using selenium package inside was we were not able to modify selenium packages directly through PR or it took time in past.
The package in the appium java-client does not contain all classes which are in the selenium package. The selenium package is much bigger than the appium one and we need those classes in our project. I.e the WebDriverException.java.
I faced that problem when upgrading from java-client.4.0.0 to java-client.6.1.0.
Currently I created my own appium library without the mentioned package, and everything works fine so far but this is only a workaround and no real solution.
When I upgraded to the java-client.6.1.0 i got following compilation error in my code:
The method domClick(WebElement, WebDriver) is ambiguous for the type MyClass
When using verion <= 4.0.0 or my customized appium java-client this works just fine.
Here a short example how to reproduce that:
public static void domClick(WebElement element, WebDriver driver) {
//Do something.
}
public static void domClick(By by, WebDriver driver) {
domClick(driver.findElement(by), driver);
}
Can we expect that this will be fixed?
Thank you @AndiCover for sharing your experience.
@SrinivasanTarget - here the problem is caused because we are using the same package name as that of Selenium classes(org.openqa.selenium).
One simple question to ourselves is: why do we need to use a selenium package name inside the appium project? If we want to have these classes in the appium project, why can not we use the appium package name similar to other classes? That should solve this, right?
It is a pain for individual developers to fork off the appium project. It is adding additional work that gives no value.
@AndiCover I have a question for you.
I have forked appium java-client git repo. In my fork I have deleted the package: org.openqa.selenium
but I am running into a bunch of compile errors. It seems like we have to fix all the imports.
Did you have to go through this process as well, or do you have an easy approach to work around this?
@AndiCover java-client.4.0.0 to java-client.6.1.0 alot has changed between these two versions over years. Why do you want to customize the java client which java client doesnt solve for you is my question.
The package in the appium java-client does not contain all classes which are in the selenium package.
exclude group: 'com.google.code.gson'
exclude module: 'htmlunit-driver'
exclude group: 'net.sourceforge.htmlunit'
Above ones are excluded from selenium and i think html unit driver has already been removed from selenium if i'm not wrong. Whats the exact problem you are facing and please feel free to raise that with errors or logs.
@vsadineni1
problem is caused because we are using the same package name as that of Selenium classes(org.openqa.selenium)
Share the details of how is it impacting you.
why do we need to use a selenium package name inside the appium project?
Exact reason why we pulled commits of selenium inside java client is because of this PR.
@vsadineni1 You are right. It seems that this does not work as I thought.
I simply removed the package: org.openqa.selenium from the jar and my compilation errors were gone. Unfortunately this is no solution.
@SrinivasanTarget I don't want to customize the java client, I have to. When using java-client.6.1.0 I cannot compile my project because of following errors:
The method domClick(WebElement, WebDriver) is ambiguous for the type MyClass
It does not matter if I have selenium and the java-client in my build.gradle file or not. After some time I found out that I get that error because of org.openqa.selenium in the java-client and removed it completely from the jar. After that I was able to successfully compile my project again.
With following class you should be able to reproduce that error:
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class MyClass {
public static void domClick(WebElement element, WebDriver driver) {
// code here
}
public static void domClick(By by, WebDriver driver) {
domClick(driver.findElement(by), driver);
}
}
Ok @vsadineni1 @AndiCover Ok no worries. Will improve this soon.
Thank you @SrinivasanTarget
It's not recommended to use both selenium java client and appium java client packages.
Moreover it is not possible because of compilation errors and because of java9 modules system restrictions (for whose who use modules).
Unfortunately I cannot follow you recommendation because I have a lot of tests which were written with 3rd-party framework which demends/compiled with selenium-java. Now I need appium-java to port all my tests to Safari/iOS. Some time ago I used selenium-java for all browsers, but recent appium version prefer W3C protocol and some command (isDisplayed/getAttribute) works incorrectly (actually does not wark at all) with selenium-java + appium
So I will appricate much if you will solve this compatibiity issue.
Hello guys,
can you please prioritize this one?
We are in the process of upgrading our java-client from 3.2.0 to some latest version. Anything >= 5.0.0 version is having the name space conflict.
Appreciate your help.
cc @SrinivasanTarget
@vsadineni1 Please change this from 'question' to 'bug' with 'critical' status. Because this BLOCKS usage of appium java-client library in the same project with selenium-java library by SeleniumHQ.
@SrinivasanTarget
I understand that some PRs was not merged long time ago. But actually they were reviewed and declined. (and I'm totally agree with reason, because PR tried to use java generics as tool for typecasting) So no chance to have your changes in official selenium client. Your advice to not use selenium client is... strange. Because appium was created and declared as tool which supports COMMON webdrdriver interface. In my tests I need to use both libraries because I work both with desktop and mobile. It is 1st time in my practice when vendor/company/group rewrites interface and republish it at the same name and package
Your advice to not use selenium client is... strange
We advice not to use java client with selenium package together was due to reason there are conflicts of version between two as its difficult to maintain backward compatibility when entire protocol changes or migrates the both dealt with. There are lot of complaints or issues since people use different version of java client which isn't compatible with selenium version they use.
Regarding duplicate classes i already mentioned in comment above that needs to be improved. If making this as a bug makes you feel better i can do so. If you are passionate about unblocking this feel free to raise a PR and we are happy to review.
Same issue for me. Is there any fix out there?
Is this on the roadmap? The issue makes it impossible to use appium in Eclipse.
I haven't been using Eclipse - I've been using both selenium and appium in a scala/sbt project, working with intelliJ. The order in which the dependencies were defined made a difference between not at all usable and being usable, though it still has some occasional headaches while working in the IDE where we have to periodically rebuild the project to resolve problems with the naming clashes.
It would also help us greatly to get this issue resolved. I'd be glad to help out.
I am using java-client and Selenium client in my project, I need both of them in project...Is there any workaround to solve this issue... I have seen that packages in selenium client is depricated...so thought to clone the selenium project and remove the packages which are deprecated and make a jar out of it...Is this a good solution? help to solve this.
@SrinivasanTarget I am setting up Appium in Android Studio and for this I have added the below Jars to Project
And below is my code to launch a Message app in Android mobile
package com.example.appiumcalc;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
public class AppiumCalc {
public static void main(String[] args) throws MalformedURLException, InterruptedException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(AUTOMATION_NAME, "Appium");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android");
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "7.0");
capabilities.setCapability("appPackage", "com.google.android.apps.messaging");
capabilities.setCapability("appActivity", "com.google.android.apps.messaging.ui.conversationlist.ConversationListActivity");
URL url = new URL("http://0.0.0.0:4723/wd/hub");
WebDriver driver = new RemoteWebDriver(url, capabilities);
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
Thread.sleep(5000);
}
}
The Error which am facing is as below :
Duplicate class org.openqa.selenium.SearchContext found in modules java-client-7.1.0.jar (java-client-7.1.0.jar) and selenium-api-3.14.0.jar (selenium-api-3.14.0.jar)
Duplicate class org.openqa.selenium.WebDriver found in modules java-client-7.1.0.jar (java-client-7.1.0.jar) and selenium-api-3.14.0.jar (selenium-api-3.14.0.jar)
Duplicate class org.openqa.selenium.WebElement found in modules java-client-7.1.0.jar (java-client-7.1.0.jar) and selenium-api-3.14.0.jar (selenium-api-3.14.0.jar)
Could you please suggest how to setup and proceed further
Thank you so much for the help.
@bradzy This is the issue we are facing from the last week, this blocks us from using appium java client along with Selenium Package, We cannot use both java-client and selenium together until unless this issue is fixed.
@vsadineni1 @SrinivasanTarget @AndiCover @kool79 Could you please suggest us on this. Its helpful if you can provide us with the jar files.
Thanks a lot!
@GullapalliAkhil which Jars you using ?
@bradzy I am using Appium/Java-client and Selenium-Standalone-Server jars, can you share the solution you have.
@GullapalliAkhil Please share the error log and the code .
@bradzy For security purpose i cannot share my code but the error which i faced is same like yours.
With the help of stackoverflow I was able to fix those issues in my projects.
See https://stackoverflow.com/questions/54604601/duplicate-classes-in-different-java-libraries-leads-to-compilation-errors
Not an optimal solution but everything works again without customizing any libraries.
I am facing the very same issue in a Android application. It has nothing but Appium in it and the buit-in Android. I am getting multiple dependencies conflicts when I am trying to import in Gradle.
This is my actual Gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "org.com.exempleapp"
minSdkVersion 24
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/spring.tooling'
exclude 'META-INF/versions/9'
exclude 'META-INF/spring.handlers'
exclude 'META-INF/license.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/spring.schemas'
exclude 'META-INF/notice.txt'
exclude 'org.apache.commons.logging'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.navigation:navigation-fragment:2.1.0'
implementation 'androidx.navigation:navigation-ui:2.1.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'io.appium:java-client:7.2.0'
}
I had to add those packagingOptions because apparently Appium (or one of its dependencies) has some config Android files within it, which conflict with Android applications.
And this is the output that I get
Duplicate class org.apache.commons.logging.Log found in modules commons-logging-1.2.jar (commons-logging:commons-logging:1.2) and spring-jcl-5.1.0.RELEASE.jar (org.springframework:spring-jcl:5.1.0.RELEASE)
Duplicate class org.apache.commons.logging.LogFactory found in modules commons-logging-1.2.jar (commons-logging:commons-logging:1.2) and spring-jcl-5.1.0.RELEASE.jar (org.springframework:spring-jcl:5.1.0.RELEASE)
Duplicate class org.apache.commons.logging.LogFactory$1 found in modules commons-logging-1.2.jar (commons-logging:commons-logging:1.2) and spring-jcl-5.1.0.RELEASE.jar (org.springframework:spring-jcl:5.1.0.RELEASE)
Duplicate class org.apache.commons.logging.impl.NoOpLog found in modules commons-logging-1.2.jar (commons-logging:commons-logging:1.2) and spring-jcl-5.1.0.RELEASE.jar (org.springframework:spring-jcl:5.1.0.RELEASE)
Duplicate class org.apache.commons.logging.impl.SimpleLog found in modules commons-logging-1.2.jar (commons-logging:commons-logging:1.2) and spring-jcl-5.1.0.RELEASE.jar (org.springframework:spring-jcl:5.1.0.RELEASE)
Duplicate class org.openqa.selenium.SearchContext found in modules java-client-7.0.0.jar (io.appium:java-client:7.0.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.0.0.jar (io.appium:java-client:7.0.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.0.0.jar (io.appium:java-client:7.0.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.0.0.jar (io.appium:java-client:7.0.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.0.0.jar (io.appium:java-client:7.0.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.0.0.jar (io.appium:java-client:7.0.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.0.0.jar (io.appium:java-client:7.0.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.0.0.jar (io.appium:java-client:7.0.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.0.0.jar (io.appium:java-client:7.0.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.0.0.jar (io.appium:java-client:7.0.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.0.0.jar (io.appium:java-client:7.0.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.0.0.jar (io.appium:java-client:7.0.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.0.0.jar (io.appium:java-client:7.0.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.0.0.jar (io.appium:java-client:7.0.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.0.0.jar (io.appium:java-client:7.0.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.0.0.jar (io.appium:java-client:7.0.0) and selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59)
Go to the documentation to learn how to Fix dependency resolution errors.
@SrinivasanTarget @mykola-mokhnach should we expect the resolution of this? It's almost impossible to use Appium within an Android app at this moment with these conflicts. I believe that renaming the Selenium, CommonsLang3 and Android package names to Appium names might fix the issue.
Hi Team, so is there a solution for this problem? I am facing the same;
Duplicate class org.openqa.selenium.SearchContext found in modules java-client-7.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.0) and selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59)
Go to the documentation to learn how to Fix dependency resolution errors.
Hi everyone
Gradle Plugin = 3.6.2
Gradle Version = 5.6.4
minSdkVersion = 21
targetSdkVersion = 29
java version = 1.8.0
Android Studion = 3.6.2
Appioum Version = 7.3.0
I have the same issue whit version 7.3.0.
I managed to exclude one of the packages in the gradle.bulid dependencies section.
But I still haven't figured out how to exclude, the selenium packages.
My inital gradle.buid:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'io.appium:java-client:7.3.0'
}
Error wen trying to run the initial android test:
More than one file was found with OS independent path 'META-INF/spring.tooling'
Modifying gradle.build, to include @felipepodolan 's packaging exclusion like this
packagingOptions {
exclude 'META-INF/spring.tooling'
exclude 'META-INF/versions/9'
exclude 'META-INF/spring.handlers'
exclude 'META-INF/license.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/spring.schemas'
exclude 'META-INF/notice.txt'
exclude 'org.apache.commons.logging'
}
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)
Then I modified the gradle.bould like this:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation ('io.appium:java-client:7.3.0'){
exclude group: 'commons-logging', module: 'commons-logging'
}
}
And got the following errors:
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)
As you can see the org.apache.commons.logging packages are no longer present in the stack trace but there are steel some issues whit the org.openqa.selenium package, but i can not seem to find any solution for this, mainly because I don't know what is the group and modul of the org.openqa.selenium classes, to exclude them the same way I did whit the org.apache.commons.logging.
Any help is appreciated, because I can not use Appium this way in my android project.
Does anybody solved this problem? I don't know what to do anymore!
In my case below exclude in gradle file helped
implementation ('io.appium:java-client:7.3.0'){
exclude group: 'commons-logging', module: 'commons-logging'
exclude group: 'org.seleniumhq.selenium', module: 'selenium-api'
}
I hope it will be useful.
@piotrekcz Do note that this also excludes several features from the Java client. While this solves the error it is not a solution.
Yes that is true. I've tried to find other better solution but i think is impossible. It have to be fixed in lib.
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 below.I have posted the answer on StackOverflow. .. check it out https://stackoverflow.com/questions/63089304/duplicate-classes-in-android-studio-when-try-study-appium/65837545#65837545
solution:
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'
}
@yosrixp , I tried your solution but I encountered this:
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/openqa/selenium/MutableCapabilities;
at java.lang.Class.newInstance(Native Method)
at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
at android.support.v4.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:43)
at android.app.Instrumentation.newActivity(Instrumentation.java:1253)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3353)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.openqa.selenium.MutableCapabilities" on path: DexPathList[[zip file "/data/app/RhrTr_LgDuVMrn-JTOyhYA==/com.medi.appiumtest-ACOQFi1mksijbD_Jxsvaog==/base.apk"],nativeLibraryDirectories=[/data/app/RhrTr_LgDuVMrn-JTOyhYA==/com.medi.appiumtest-ACOQFi1mksijbD_Jxsvaog==/lib/x86, /system/lib, /system_ext/lib, /product/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
Do you have any workaround for this?
Hi @zero03
Actually i was helping one of my team mate on compiling the code without an issue.. she didn't verify yet if all things work fine at runtime..
however i looked into dependency:tree and i notice selenium-api get remove completely and because of that you got this exception..
i have workaround and it might work for you .
Add this dependency again after io.appium:java-client:7.3.0 dep definition and give it try.
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"
}
testImplementation('org.seleniumhq.selenium:selenium-java:3.141.59')
t's kind of tricky you tell gradle that selenium-java is provided and only do compilation and then you exclude selenium-api from appium this will lead you to that exception at runtime then by adding testImplementation again for selenium-java will included..
Hope that help.
Most helpful comment
Hi Team, so is there a solution for this problem? I am facing the same;
Duplicate class org.openqa.selenium.SearchContext found in modules java-client-7.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.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.3.0.jar (io.appium:java-client:7.3.0) and selenium-api-3.141.59.jar (org.seleniumhq.selenium:selenium-api:3.141.59)
Go to the documentation to learn how to Fix dependency resolution errors.