我想在现有项目中设置androidTests。Android设置androidTestCompile
继谷歌官方指导我添加以下的依赖:
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'org.robolectric:robolectric:3.1.2'
androidTestCompile 'org.assertj:assertj-core:3.5.2'
androidTestCompile 'com.android.support:support-annotations:25.3.1'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
的第一个问题是,认为有在APK中的多个confilicting文件(一式两份):
packagingOptions {
pickFirst '.readme'
pickFirst 'META-INF/LICENSE.txt'
pickFirst 'META-INF/plexus/components.xml'
pickFirst 'META-INF/NOTICE.txt'
pickFirst 'META-INF/MANIFEST.MF'
pickFirst 'licenses/thoughtworks.TXT'
pickFirst 'licenses/javolution.license.TXT'
pickFirst 'licenses/extreme.indiana.edu.license.TXT'
pickFirst 'org/apache/maven/project/pom-4.0.0.xml'
pickFirst 'org/codehaus/plexus/plexus-bootstrap.xml'
pickFirst 'org/cyberneko/html/res/HTMLlat1.properties'
pickFirst 'org/cyberneko/html/res/HTMLsymbol.properties'
pickFirst 'org/cyberneko/html/res/XMLbuiltin.properties'
pickFirst 'org/cyberneko/html/res/HTMLspecial.properties'
pickFirst 'org/cyberneko/html/res/ErrorMessages_ja.properties'
pickFirst 'org/cyberneko/html/res/ErrorMessages.properties'
pickFirst 'org/cyberneko/html/res/ErrorMessages_ja.txt'
pickFirst 'org/cyberneko/html/res/ErrorMessages.txt'
pickFirst 'META-INF/LICENSE'
pickFirst 'META-INF/DEPENDENCIES'
}
排除后重复的,我结束了约1700警告关于类,超类和界面哪些找不到,以及错误:
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForMediadeDebugAndroidTest'.
> Job failed, see logs for details
我真的不知道要在哪些部分进一步查看,以使测试工作。
编辑:这里是Gradle Logs
请从**摇篮控制台分享日志**。 –
https://gist.githubusercontent.com/4ndro1d/92c7f210fa6dddf48feb63a75529eaad/raw/4de36bd98e274b7726d03fd539306649b30f4555/Gradle%2520Log希望此链接有效 – 4ndro1d
您发布的日志似乎没有任何*错误*。看来你正在使用ProGuard进行测试?为什么要在运行测试时这么做? –