Appium/Selenium TestNG Gradle DexArchiveBulder异常生成错误



我是一名中级测试人员,目前正在探索移动自动化的选项。我熟悉Appium/Selenium,现在正尝试引入TestNG来管理测试套件。

我在尝试构建一个简单的项目以使用TestNG和Appium/Selenium开始移动测试时遇到了一个错误。我不知道如何修复这个错误。

这是我的建筑.gradle:

apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.mikejohnson.testngtest"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9' // added this to resolve initial build conflict
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'org.testng:testng:6.11' //added this
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'org.seleniumhq.selenium:selenium-java:3.7.1' //added this
implementation 'io.appium:java-client:5.0.4' //added this
}

错误如下:

Information:Gradle tasks [clean, :app:assembleDebug]
Warning:Ignoring InnerClasses attribute for an anonymous inner class
Error:com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:UsersMike.Johnson.gradlecachesmodules-2files-2.1org.seleniumhq.seleniumselenium-firefox-driver3.7.1460c39abe149b7c649dd05dd71ab64ca80f738aaselenium-firefox-driver-3.7.1.jar
Error:com.android.builder.dexing.DexArchiveBuilderException: Error while dexing org/openqa/selenium/firefox/FirefoxBinary.class
Error:com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:UsersMike.Johnson.gradlecachesmodules-2files-2.1org.seleniumhq.seleniumselenium-firefox-driver3.7.1460c39abe149b7c649dd05dd71ab64ca80f738aaselenium-firefox-driver-3.7.1.jar
Information:BUILD FAILED in 10s
Information:4 errors
Information:1 warning
Information:See complete output in console

为了达到这一点,我所做的就是创建一个基本的android项目,并试图将TestNG和Appium/Selenium所需的依赖项添加到build.gradle 中

这些错误是在组合TestNG和Appium/Selenium的依赖项时引入的。该项目能够仅使用TestNG依赖项或Appium/Selenium依赖项成功构建。当我将TestNG与Appium/Selenium结合在一起时,错误就开始出现。

我已经搜索并尝试了许多可能的解决方案,但它总是以DexArchiveBulderException结束。我没有经验推断依赖关系出了什么问题,搜索时"DexArchiveBuilderException"上的可用信息也很少。

如果我能提供任何其他信息,请告诉我。感谢您提前提供的帮助。

最初的问题是您试图在Android项目中创建Selenium测试,至少看起来您正在向Android项目中的build.gradle添加依赖项。

这真是一个奇怪的开始。看看官方的Appium java客户端测试,了解如何设计项目

问题修复-在Intellij IDEA中重新创建项目作为基本的gradle/java项目。

最新更新