- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有一个 Android 项目,其中包含一个 MultiDex
应用程序。
我正在尝试使用 ./gradlew clean connectedAndroidTest
运行 Espresso 测试。此命令最终导致此错误消息:
:app:dexDebugAndroidTest
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Landroid/support/test/InstrumentationRegistry;
我的顶级 build.gradle
包含:
classpath 'com.android.tools.build:gradle:1.2.3'
我通过包装器使用 Gradle 2.4。
我项目的 build.gradle
是这样的:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.robolectric:robolectric-gradle-plugin:1.0.1'
// classpath 'me.tatarka:gradle-retrolambda:3.1.0'
}
}
apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'
//apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'org.robolectric'
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.something"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "com.android.test.runner.MultiDexTestRunner"
}
dexOptions {
javaMaxHeapSize "2g"
preDexLibraries = false
}
buildTypes {
debug {
versionNameSuffix '-DEBUG'
minifyEnabled false
shrinkResources = false
zipAlignEnabled = false
}
release {
minifyEnabled false
shrinkResources = true
zipAlignEnabled = true
}
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt' }
}
dependencies {
//compile 'com.google.dexmaker:dexmaker:1.0'
compile 'com.android.support:multidex:1.0.1'
// Auth0
compile 'com.auth0.android:lock:1.7.0'
compile 'com.auth0.android:lock-googleplus:1.7.0'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.squareup.picasso:picasso:2.1.1'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.google.android.gms:play-services-plus:7.3.0'
compile 'io.reactivex:rxandroid:0.24.0'
compile 'com.amazonaws:aws-android-sdk-cognito:2.2.1'
compile 'com.amazonaws:aws-android-sdk-core:2.2.1'
compile 'com.amazonaws:aws-android-sdk-mobileanalytics:2.2.1'
// Robolectric
//testCompile 'junit:junit:4.12'
testCompile "org.robolectric:robolectric:3.0-rc3"
testCompile "org.robolectric:shadows-multidex:3.0-rc3" // otherwise robolectric tests fail on MultiDex.install
androidTestCompile ('com.android.support.test:rules:0.2') {
exclude module: 'support-v4'
exclude module: 'support-annotations'
}
androidTestCompile ('com.android.support.test:testing-support-lib:0.1') {
exclude group: 'junit'
}
androidTestCompile ('com.android.support.test.espresso:espresso-core:2.0') {
exclude module: 'testing-support-lib'
exclude module: 'support-v4'
exclude module: 'support-annotations'
exclude group: 'javax.inject'
}
}
robolectric {
// Configure includes / excludes
include '**/*Test.class'
exclude '**/espresso/**/*.class'
// Configure max heap size of the test JVM
maxHeapSize = '2048m'
// Configure the test JVM arguments - Does not apply to Java 8
//jvmArgs '-XX:MaxPermSize=512m', '-XX:-UseSplitVerifier'
// Specify max number of processes (default is 1)
maxParallelForks = 4
// Specify max number of test classes to execute in a test process
// before restarting the process (default is unlimited)
forkEvery = 150
// configure whether failing tests should fail the build
ignoreFailures true
// use afterTest to listen to the test execution results
afterTest { descriptor, result ->
println "Executing test for ${descriptor.name} with result: ${result.resultType}"
}
}
现在我一直在试图弄清楚发生了什么,例如通过使用 ./gradlew -q app:dependencies
查看依赖关系,结果(以及其他内部配置):
androidJacocoAgent - The Jacoco agent to use to get coverage data.
\--- org.jacoco:org.jacoco.agent:0.7.4.201502262128
androidJacocoAnt - The Jacoco ant tasks to use to get execute Gradle tasks.
\--- org.jacoco:org.jacoco.ant:0.7.4.201502262128
+--- org.jacoco:org.jacoco.core:0.7.4.201502262128
| \--- org.ow2.asm:asm-debug-all:5.0.1
+--- org.jacoco:org.jacoco.report:0.7.4.201502262128
| +--- org.jacoco:org.jacoco.core:0.7.4.201502262128 (*)
| \--- org.ow2.asm:asm-debug-all:5.0.1
\--- org.jacoco:org.jacoco.agent:0.7.4.201502262128
androidTestCompile - Classpath for compiling the androidTest sources.
+--- com.android.support.test:rules:0.2
| \--- com.android.support.test:runner:0.2
| +--- junit:junit-dep:4.10
| | \--- org.hamcrest:hamcrest-core:1.1
| \--- com.android.support.test:exposed-instrumentation-api-publish:0.2
+--- com.android.support.test:testing-support-lib:0.1
\--- com.android.support.test.espresso:espresso-core:2.0
+--- com.squareup:javawriter:2.1.1
+--- org.hamcrest:hamcrest-integration:1.1
| \--- org.hamcrest:hamcrest-core:1.1
+--- org.hamcrest:hamcrest-library:1.1
| \--- org.hamcrest:hamcrest-core:1.1
+--- com.android.support.test.espresso:espresso-idling-resource:2.0
+--- com.google.code.findbugs:jsr305:2.0.1
+--- javax.annotation:javax.annotation-api:1.2
\--- org.hamcrest:hamcrest-core:1.1
compile - Classpath for compiling the main sources.
+--- com.android.support:multidex:1.0.1
+--- com.auth0.android:lock:1.7.0
| +--- com.android.support:appcompat-v7:22.0.0 -> 22.1.1
| | \--- com.android.support:support-v4:22.1.1
| | \--- com.android.support:support-annotations:22.1.1
| +--- com.squareup:otto:1.3.5
| +--- com.auth0.android:identity-core:1.7.0
| | +--- com.hannesdorfmann.smoothprogressbar:library:1.0.0
| | +--- com.android.support:appcompat-v7:21.0.2 -> 22.1.1 (*)
| | \--- com.auth0.android:core:1.7.0
| | +--- com.fasterxml.jackson.core:jackson-annotations:2.4.1
| | +--- com.fasterxml.jackson.core:jackson-core:2.4.1
| | +--- com.loopj.android:android-async-http:1.4.5
| | \--- com.fasterxml.jackson.core:jackson-databind:2.4.1
| | +--- com.fasterxml.jackson.core:jackson-annotations:2.4.0 -> 2.4.1
| | \--- com.fasterxml.jackson.core:jackson-core:2.4.1
| \--- com.auth0.android:core:1.7.0 (*)
+--- com.auth0.android:lock-googleplus:1.7.0
| +--- com.android.support:appcompat-v7:21.0.2 -> 22.1.1 (*)
| +--- com.auth0.android:identity-core:1.7.0 (*)
| \--- com.google.android.gms:play-services-plus:6.5.87 -> 7.3.0
| \--- com.google.android.gms:play-services-base:7.3.0
| \--- com.android.support:support-v4:22.0.0 -> 22.1.1 (*)
+--- com.android.support:appcompat-v7:22.1.1 (*)
+--- com.google.code.gson:gson:2.3.1
+--- com.squareup.picasso:picasso:2.1.1
+--- com.squareup.retrofit:retrofit:1.9.0
| \--- com.google.code.gson:gson:2.3.1
+--- com.squareup.okhttp:okhttp:2.4.0
| \--- com.squareup.okio:okio:1.4.0
+--- com.google.android.gms:play-services-plus:7.3.0 (*)
+--- io.reactivex:rxandroid:0.24.0
| \--- io.reactivex:rxjava:1.0.4
+--- com.amazonaws:aws-android-sdk-cognito:2.2.1
| \--- com.amazonaws:aws-android-sdk-core:2.2.1
| +--- commons-logging:commons-logging:1.1.1
| \--- com.google.code.gson:gson:2.2.4 -> 2.3.1
+--- com.amazonaws:aws-android-sdk-core:2.2.1 (*)
\--- com.amazonaws:aws-android-sdk-mobileanalytics:2.2.1
\--- com.amazonaws:aws-android-sdk-core:2.2.1 (*)
testCompile - Classpath for compiling the test sources.
+--- org.robolectric:robolectric:3.0-rc3
| +--- junit:junit:4.8.2
| +--- org.robolectric:robolectric-annotations:3.0-rc3
| +--- org.robolectric:robolectric-resources:3.0-rc3
| | +--- org.robolectric:robolectric-utils:3.0-rc3
| | | +--- org.robolectric:robolectric-annotations:3.0-rc3
| | | \--- com.google.android.apps.common.testing.accessibility.framework:accessibility-test-framework:1.0
| | +--- org.robolectric:robolectric-annotations:3.0-rc3
| | \--- com.ximpleware:vtd-xml:2.11
| +--- org.robolectric:robolectric-utils:3.0-rc3 (*)
| +--- org.robolectric:shadows-core:3.0-rc3
| | +--- org.robolectric:robolectric-annotations:3.0-rc3
| | +--- org.robolectric:robolectric-utils:3.0-rc3 (*)
| | +--- org.robolectric:robolectric-resources:3.0-rc3 (*)
| | +--- com.ibm.icu:icu4j:53.1
| | \--- com.almworks.sqlite4java:sqlite4java:0.282
| +--- org.bouncycastle:bcprov-jdk16:1.46
| +--- org.ow2.asm:asm:5.0.1
| +--- org.ow2.asm:asm-commons:5.0.1
| | \--- org.ow2.asm:asm-tree:5.0.1
| | \--- org.ow2.asm:asm:5.0.1
| +--- org.ow2.asm:asm-util:5.0.1
| | \--- org.ow2.asm:asm-tree:5.0.1 (*)
| +--- org.ow2.asm:asm-analysis:5.0.1
| | \--- org.ow2.asm:asm-tree:5.0.1 (*)
| +--- com.ximpleware:vtd-xml:2.11
| +--- org.apache.maven:maven-ant-tasks:2.1.3
| \--- org.apache.ant:ant:1.8.0
| \--- org.apache.ant:ant-launcher:1.8.0
\--- org.robolectric:shadows-multidex:3.0-rc3
\--- org.robolectric:robolectric:3.0-rc3 (*)
现在我的问题是,我该如何着手找出导致重复的原因?据我了解,它应该是某个库,其中包括另一个定义 InstrumentationRegistry
的库。
最佳答案
来自 Espresso 2.1 release notes :
“...测试运行器构件一分为二,名称从 com.android.support.test:testing-support-lib:0.1 更改为 com.android.support.test:runner:0.2 + com .android.support.test:rules:0.2...”
在您的依赖项中,您通过包含旧的 testing-support-lib 和新规则来混合两个测试运行器。
因此,您要么通过添加 runner:0.2 依赖项而不是旧的 support-lib 完全切换到新的测试运行器,要么选择不使用规则。
如果您想遵守规则,您的 androidTest 依赖项将如下所示:
androidTestCompile('com.android.support.test:rules:0.2') {
exclude module: 'support-v4'
exclude module: 'support-annotations'
}
androidTestCompile('com.android.support.test:runner:0.2') {
exclude module: 'support-annotations'
}
androidTestCompile('com.android.support.test.espresso:espresso-core:2.0') {
exclude module: 'testing-support-lib'
exclude module: 'support-v4'
exclude module: 'support-annotations'
exclude group: 'javax.inject'
}
关于android - Gradle 依赖 : How to figure out what's causing this duplication,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30507934/
我有一个内部表,里面有 108 个条目。从 9 到 9 个条目重复条目,我想删除这些重复项。由于它们完全相同,我使用了 delete adjacent duplicates from itab com
在 Team Foundation Server (TFS) 中链接两个工作项 (WI) 时,在什么情况下将“Duplicate”和“Duplicate Of”区分为“链接类型”是有意义的? 如何处理
ld: duplicate symbol _velocityX in \ /Users/Student/Library/Developer/Xcode/DerivedData/finalproject
我使用 PHP 和 Mysql。 此 SQL 有效: INSERT INTO products (id, title, description) VALUES (10, 'va
我有一个大数据框 (120000x40),我尝试在每一行中找到重复项并显示它们。这就是我的尝试: 创建数据框 import pandas as pd df = pd.DataFrame({'col1'
我是 mySQL 和 PHP 的新手,请多多包涵。 如果我的查询有重复字段,我该如何做到这一点,检索到的数据将具有重复查询字段的重复数据。 一个例子是这样的: 查询 id = 34, 54, 21,
我一直遇到这个错误,但我无法理解它,因为它提示一个值恰好出现一次。 Exception in thread "main" java.lang.IllegalStateException: Duplic
我有一个带有 Vuejs 和 Laravel 的 Web 应用程序 我想使用 CKEditor 5 我安装了依赖项 npm install --save @ckeditor/ckeditor5-vue
我有一个包含以下数据的 csv 文件: Id,Name,Type,date 1,name1,employee,25/04/2017 2,name2,contrator,26/04/2017 3,nam
import CKEditor from '@ckeditor/ckeditor5-react'; import ClassicEditor from '@ckeditor/ckeditor5-bui
表定义: CREATE TABLE PositionalDataNGS ( Date DATE, Time TIME(3) , X FLOAT(5), Y FLOAT(5), D FLOAT(5) ,
我目前正在做一个项目,我要处理数以千计的数据包。现在,我记录每个数据包的 IP 和 MAC 地址以及一些其他信息。为了存储所有这些,我使用 MySQL 并且我的脚本是用 Node.js 编写的。目前我
I am using MySQL 5.1.56, MyISAM. My table looks like this:我使用的是MySQL 5.1.56,MyISAM。我的桌子是这样的: CR
我是新来的,对 SQL 比较陌生。我有一个类似这样的表: [Pk], [Case_No], [Status], [Open_Date], [Close_Date], [Case_Age], [Repo
为什么会收到此警告? warning No duplicate props allowed react/jsx-no-duplicate-props# 它显示的是第28行,但没有使用 Prop 。 最
是否有任何函数或方法可以在 python 2.7 中递归实现此目的? Input : ['and', ['or', 'P', '-R', 'P'], ['or', '-Q', '-R', 'P']]
我正在分析 hadoop 中的数据。有一些重复条目,其中 A、B 列重复,而 C 列不同。我想要做的是仅识别 A、B 重复项,然后为每个重复项打印出 C 列的不同值。 示例数据: row, data
您好,感谢阅读并可能对我有所帮助 我的问题的简要说明: 我正在将数据从一个 Firebird 数据库复制到另一个(称为 V14),并且我正在使用 IBExpert 来执行此操作。这些表的名称相同并且具
我想制作一张很像下面的图片: 我想使用 seaborn 使图表看起来漂亮,并让我自己以后更容易使用 facetgrids(我有十个不同的数据集,我想在同一个图表中显示。) 我在 seaborn 中找到
我在两列“user_id”和“project_id”上有一个复合唯一键。 当我尝试对单行或多行运行 DELETE 查询时,出现错误。 ERROR 1062: 1062: Duplicate entry
我是一名优秀的程序员,十分优秀!