首页 > 解决方案 > Android 无法创建 APK 文件

问题描述

我有一个简单的测试项目,我需要 .apk 文件才能在 Browserstack 中使用,但是当我尝试这样做时,我得到了错误:

Duplicate class org.apache.commons.logging.Log found in modules commons-logging-1.2 (commons-logging:commons-logging:1.2) and spring-jcl-5.3.4 (org.springframework:spring-jcl:5.3.4)
Duplicate class org.apache.commons.logging.LogFactory found in modules commons-logging-1.2 (commons-logging:commons-logging:1.2) and spring-jcl-5.3.4 (org.springframework:spring-jcl:5.3.4)
Duplicate class org.apache.commons.logging.LogFactory$1 found in modules commons-logging-1.2 (commons-logging:commons-logging:1.2) and spring-jcl-5.3.4 (org.springframework:spring-jcl:5.3.4)
Duplicate class org.apache.commons.logging.impl.NoOpLog found in modules commons-logging-1.2 (commons-logging:commons-logging:1.2) and spring-jcl-5.3.4 (org.springframework:spring-jcl:5.3.4)
Duplicate class org.openqa.selenium.WebDriver$Window found in modules java-client-7.5.1 (io.appium:java-client:7.5.1) and selenium-api-3.141.59 (org.seleniumhq.selenium:selenium-api:3.141.59)
Duplicate class org.openqa.selenium.WebElement found in modules java-client-7.5.1 (io.appium:java-client:7.5.1) and selenium-api-3.141.59 (org.seleniumhq.selenium:selenium-api:3.141.59)
Duplicate class org.openqa.selenium.internal.FindsByClassName found in modules java-client-7.5.1 (io.appium:java-client:7.5.1) and selenium-api-3.141.59 (org.seleniumhq.selenium:selenium-api:3.141.59)
Duplicate class org.openqa.selenium.internal.FindsByCssSelector found in modules java-client-7.5.1 (io.appium:java-client:7.5.1) and selenium-api-3.141.59 (org.seleniumhq.selenium:selenium-api:3.141.59)
Duplicate class org.openqa.selenium.internal.FindsById found in modules java-client-7.5.1 (io.appium:java-client:7.5.1) and selenium-api-3.141.59 (org.seleniumhq.selenium:selenium-api:3.141.59)


//and so on

Go to the documentation to learn how to Fix dependency resolution errors.

这个项目是从头开始制作的,但不知怎的,我遇到了很多冲突。

build.gradle file

    plugins {
        id 'com.android.application'
    }

    android {
        compileSdkVersion 30
        buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.example.mobiletest"
        minSdkVersion 18
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    }
    
    dependencies {


    implementation group: 'io.appium', name: 'java-client', version: '7.5.1'
    testImplementation group: 'org.testng', name: 'testng', version: '7.4.0'

    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'

    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

当我运行我的测试方法时,它工作正常,但我无法创建 .apk

标签: javaandroidappium

解决方案


推荐阅读