gpt4 book ai didi

android - 尝试学习 Appium 时在 Android Studio 中复制类

转载 作者:行者123 更新时间:2023-12-04 09:21:51 26 4
gpt4 key购买 nike

我在使用 Appium java 客户端时遇到问题,我尝试重启 Android Studio,在谷歌搜索中使用一些解决方案,但我仍然无法修复它们。

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");
}
}

这是我的 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'

}

这是我构建时的结果:

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)

希望有人帮帮我!谢谢!!!

最佳答案

我遇到了同样的问题,我能够通过从 io.appium:java-client 中排除 selenium-api 并将 selenium-java 定义为 compileOnly 范围来解决依赖项重复。这是我的 build.gradle 部门

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'

关于android - 尝试学习 Appium 时在 Android Studio 中复制类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63089304/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com