【问题标题】:Error: More than one file was found with OS independent path 'META-INF/DEPENDENCIES'错误:发现多个文件具有独立于操作系统的路径“META-INF/DEPENDENCIES”
【发布时间】:2018-08-04 03:51:56
【问题描述】:

我在 Java 中使用 Selenium 来制作应用程序。我不断收到此错误,我一直在搜索互联网以找出问题所在,但我找不到任何东西。请帮忙。

这是我的 build.gradle:

    android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "luke.luke.seleniumtest"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}



dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation files('libs/byte-buddy-1.7.9.jar')
    implementation files('libs/client-combined-3.9.1.jar')
    implementation files('libs/commons-codec-1.10.jar')
    implementation files('libs/commons-exec-1.3.jar')
    implementation files('libs/commons-logging-1.2.jar')
    implementation files('libs/gson-2.8.2.jar')
    implementation files('libs/guava-23.6-jre.jar')
    implementation files('libs/httpclient-4.5.3.jar')
    implementation files('libs/httpcore-4.4.6.jar')
    implementation files('libs/okhttp-3.9.1.jar')
    implementation files('libs/okio-1.13.0.jar')
}

【问题讨论】:

    标签: java android selenium gradle build.gradle


    【解决方案1】:

    简单的解决方案而不是排除它就是做

    android {
        packagingOptions {
            pickFirst  'META-INF/*'
        }
    }
    

    【讨论】:

      【解决方案2】:

      首先,尝试添加这一行:排除'META-INF/DEPENDENCIES',然后运行'app'

      android {
          packagingOptions {
              exclude 'META-INF/DEPENDENCIES'
          }
      }
      

      如果错误继续出现:'META-INF/INDEX.LIST',继续添加排除'META-INF/INDEX.LIST':

      android {
          packagingOptions {
              exclude 'META-INF/DEPENDENCIES'
              exclude 'META-INF/INDEX.LIST'
          }
      }
      

      我成功了!

      【讨论】:

      • 这迫使我将 minsdk 更改为 26。它还导致:java.lang.RuntimeException:无法实例化活动
      • 我添加了 youtube 库,然后我遇到了这个问题。就我而言,第二个答案对我有用。
      【解决方案3】:

      尝试添加包装选项

      android {
          packagingOptions {
              exclude 'META-INF/DEPENDENCIES'
          }
      }
      

      【讨论】:

      • 然后我得到错误:错误:com.android.builder.dexing.DexArchiveBuilderException:无法处理/Users/luke/AndroidStudioProjects/SeleniumTest/app/libs/client-combined-3.9.1。 jar 错误:com.android.builder.dexing.DexArchiveBuilderException:dexing org/openqa/selenium/logging/LogCombiner.class 时出错。错误:com.android.dx.cf.code.SimException:无效的操作码 ba(invokedynamic 需要 --min-sdk-version >= 26)
      • 你的 gradle 版本是什么?并检查this
      • 将 minSdkVersion 改为 26
      • 这不适用于我的应用程序。它将允许极少数人使用它。
      • @LUKER 你找到解决办法了吗,我也遇到了同样的问题。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-02
      • 1970-01-01
      相关资源
      最近更新 更多