【问题标题】:Appium/Selenium TestNG Gradle DexArchiveBulderException Build ErrorsAppium/Selenium TestNG Gradle DexArchiveBulderException 构建错误
【发布时间】:2018-04-28 04:59:07
【问题描述】:

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

我在尝试使用 TestNG 和 Appium/Selenium 构建一个简单的项目以开始移动测试时遇到了错误。我无法弄清楚如何解决此错误。

这是我的 build.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:\Users\Mike.Johnson\.gradle\caches\modules-2\files-2.1\org.seleniumhq.selenium\selenium-firefox-driver\3.7.1\460c39abe149b7c649dd05dd71ab64ca80f738aa\selenium-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:\Users\Mike.Johnson\.gradle\caches\modules-2\files-2.1\org.seleniumhq.selenium\selenium-firefox-driver\3.7.1\460c39abe149b7c649dd05dd71ab64ca80f738aa\selenium-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”上的可用信息非常少。

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

【问题讨论】:

    标签: selenium gradle build testng appium


    【解决方案1】:

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

    这是一种很奇怪的开始方式。看看官方Appium java-client tests了解如何设计项目

    【讨论】:

    • 对不起,我应该更具体一些;我正准备使用 appium 进行移动自动化。我已经熟悉 Selenium。
    • 我更新了答案。您需要创建单独的项目并在具有适当配置(JVM、Android SDK 等)的 PC/VM 上运行测试
    • 我已经熟悉 appium 并已将其设置为使用 Android SDK 等运行测试。我正在使用 Android Studio。这对我没有帮助。我需要帮助弄清楚为什么 TestNG 依赖项与 Appium/Selenium 冲突,以及如何解决。谢谢
    • 再一次:不要在 Android Studio 中创建 appium 测试等等——这是 Android 项目的一部分。它行不通。您面临的冲突是您正在尝试在 Android 项目中构建自动化测试项目并混合依赖项,但它不能以这种方式工作。如果您创建简单的 java 项目并仅添加 appium 和 testng 依赖项,它将完美运行
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2015-07-02
      • 2016-10-21
      • 2016-02-22
      • 2016-05-08
      • 2015-06-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多