无法解析符号'AndroidJUnit4“ [英] Cannot resolve symbol 'AndroidJUnit4'
问题描述
很显然,我需要正确的导入说明书来解决这个问题。按照文档的 AndroidJUnit4
< /一>,这应该是
进口android.support.test.runner.AndroidJUnit4;
当我做到这一点,在红色的机器人工作室的亮点亚军
并抱怨无法解析符号'跑步'。
背景
我按照在Android开发者网站上的教程设立了这一点使用用户界面的Automator 测试。我遇到的第一个问题是, com.android.support:support-v4:22.2.0
和 com.android.support.test:亚军: 0.2
取决于不同版本的 com.android.support:support-annotations
的。我跟着从这款Android bug报告并添加以下为 allprojects
我的项目的 build.gradle
:
configurations.all { resolutionStrategy.forcecom.android.support:support-annotations:22.1.0 }
这解决了眼前的错误,但我怀疑它导致我国目前存在的问题。有没有人有关于如何解决这个问题有什么建议?
相应和从`./gradlew部分:应用程序:依赖
androidTestCompile - 类路径编译androidTest来源。
+ --- com.jayway.android.robotium:robotium独奏:5.2.1
+ --- com.squareup:巨星 - 安卓1.0.8
| \ --- org.easytesting:巨星断言核心:2.0M10
| \ --- org.easytesting:巨星 - UTIL:1.2.5
+ --- com.android.support.test:亚军:0.2
| + - 的JUnit:JUnit的-DEP:4.10
| | \ --- org.hamcrest:hamcrest芯:1.1
| + --- com.android.support.test:外露仪表-API的发布:0.2
| \ --- com.android.support:support-annotations:22.0.0 - &GT; 22.2.0
+ --- com.android.support.test:规则:0.2
| \ --- com.android.support.test:亚军:0.2(*)
\ --- com.android.support.test.uiautomator:uiautomator-V18:2.1.0
编译 - 类路径编制的主要来源。
+ --- com.android.support:appcompat-v7:22.2.0
| \ --- com.android.support:support-v4:22.2.0
| \ --- com.android.support:support-annotations:22.2.0
+ --- com.android.support:support-v4:22.2.0(*)
+ --- com.google.android.gms:播放服务:71年6月1日
| \ --- com.android.support:support-v4:20.0.0 - &GT; 22.2.0(*)
+ --- com.crashlytics.android:crashlytics:1.+ - &GT; 1.1.13
\ --- com.jakewharton:butterknife:5.1.2
我发现的此处有测试支持库比我用的是较新的版本:
相关性{
androidTestCompilecom.android.support.test:亚军:0.3
androidTestCompilecom.android.support.test:规则:0.3
androidTestCompilecom.android.support.test.uiautomator:uiautomator-V18:2.1.1
}
在特定的,亚军0.3版似乎解决了依赖问题,我刚才遇到的,使这个问题完全没有实际意义。
Obviously I need the correct import statment to solve this problem. According to the docs for AndroidJUnit4
, this should be
import android.support.test.runner.AndroidJUnit4;
When I do that, Android Studio highlights runner
in red and complains "Cannot resolve symbol 'runner'".
Background
I got to this point by following the tutorials on the Android Developer site for setting up tests using UI Automator. The first problem I encountered was that com.android.support:support-v4:22.2.0
and com.android.support.test:runner:0.2
depend on different versions of com.android.support:support-annotations
. I followed the suggestions from this Android bug report and added the following to allprojects
in my project's build.gradle
:
configurations.all { resolutionStrategy.force 'com.android.support:support-annotations:22.1.0' }
This solved the immediate error, but I suspect it lead to my current problems. Does anyone have any suggestions about how to fix this?
Relevent sections from `./gradlew :app:dependencies
androidTestCompile - Classpath for compiling the androidTest sources.
+--- com.jayway.android.robotium:robotium-solo:5.2.1
+--- com.squareup:fest-android:1.0.8
| \--- org.easytesting:fest-assert-core:2.0M10
| \--- org.easytesting:fest-util:1.2.5
+--- 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:support-annotations:22.0.0 -> 22.2.0
+--- com.android.support.test:rules:0.2
| \--- com.android.support.test:runner:0.2 (*)
\--- com.android.support.test.uiautomator:uiautomator-v18:2.1.0
compile - Classpath for compiling the main sources.
+--- com.android.support:appcompat-v7:22.2.0
| \--- com.android.support:support-v4:22.2.0
| \--- com.android.support:support-annotations:22.2.0
+--- com.android.support:support-v4:22.2.0 (*)
+--- com.google.android.gms:play-services:6.1.71
| \--- com.android.support:support-v4:20.0.0 -> 22.2.0 (*)
+--- com.crashlytics.android:crashlytics:1.+ -> 1.1.13
\--- com.jakewharton:butterknife:5.1.2
I found here that there are newer versions of the Testing Support Library than what I was using:
dependencies {
androidTestCompile 'com.android.support.test:runner:0.3'
androidTestCompile 'com.android.support.test:rules:0.3'
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
}
In particular, runner version 0.3 seems to solve the dependency problems I encountered earlier and makes this question completely moot.
这篇关于无法解析符号'AndroidJUnit4“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!