Android Studio - 已下载Espresso jar但未检测到导入

时间:2016-06-06 05:53:29

标签: java android android-studio android-espresso

我已将expresso gradle依赖项纳入我的项目中。

的build.gradle:

androidTestCompile 'com.android.support.test:runner:0.4.1'
androidTestCompile 'com.android.support.test:rules:0.4.1'
androidTestCompile 'com.android.support:support-annotations:23.4.0'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'

它已经下载了jar,它在外部库中可见:

expresso-import

但是在课堂上使用它们时未检测到导入。例如:当我写onView(withId(R.id.textView)).perform( ...时,android studio报告 - cannot resolve symbol - onView

我尝试了无效缓存和重建。我在这里错过了什么吗?

import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;


@RunWith(AndroidJUnit4.class)
@LargeTest
public class RegisterActivityTest {

    @Rule
    public ActivityTestRule<RegisterActivity> mRegisterActivity = new ActivityTestRule
            <>(RegisterActivity.class);

    @Test
    public void test_text_views() {
        onView. // onView is not imported directly. Even force use of android.support.test.espresso.Espresso.onView does not work
    }
}

0 个答案:

没有答案