导入问题 android.support.test。*

issue with importing android.support.test.*

我将此 依赖项添加到 gradle:

// 单元测试依赖

testCompile 'junit:junit:4.12'

// 如果要使用 Hamcrest 匹配器库,请设置此依赖项

testCompile 'org.hamcrest:hamcrest-library:1.3'

// 更多内容,例如 Mockito

androidTestCompile 'org.mockito:mockito-core:1.+'
androidTestCompile "com.google.dexmaker:dexmaker:1.2"
androidTestCompile "com.google.dexmaker:dexmaker-mockito:1.2"

androidTestCompile 'com.android.support.test:runner:0.3'
androidTestCompile 'com.android.support.test:rules:0.3'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'

// 添加这个用于意图模拟支持

androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2'

// 添加这个用于 webview 测试支持

 androidTestCompile 'com.android.support.test.espresso:espresso-web:2.2'

并同步 build.gradle 成功,但是当我想导入这个 类 :

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;

IDE (Android Studio 1.2) 给我一个无法解析符号测试的错误,我搜索太多但没有找到任何答案

我发现了我的错,在 Android Studio 中转到 file/settings/compiler 并取消选中 Use-in-process 构建然后测试将工作