Gradle Espresso包装无法识别

时间:2015-08-20 16:34:20

标签: android android-espresso

我无法导入浓缩咖啡包

这是我的app gradle文件

apply plugin: 'com.android.application'

android {
signingConfigs {
    config {
        keyAlias 'XXXXX'
        keyPassword 'XXXXX'
        storeFile file('XXXX')
        storePassword 'XXXX'
    }
}
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
    applicationId 'my.package.name'
    minSdkVersion 15
    targetSdkVersion 19
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.config
    }
}
productFlavors {
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}
}


dependencies {
compile 'com.android.support:multidex:1.0.0'
compile project(':customlib1')
compile project(':customlib2')

compile 'com.android.support:support-annotations:22.2.0'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'
androidTestCompile 'com.android.support.test:runner:0.3'
androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2'

}

我只是清理并重建我的项目并更新库,但是当我尝试在我的测试中使用

import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.LargeTest;

import com.estratek.postreet.postreet_lib.activities.About;

import static java.util.regex.Pattern.matches;

@LargeTest
public class EspressoTest extends  ActivityInstrumentationTestCase2<About> {

public EspressoTest() {
    super(About.class);
}

@Override
public void setUp() throws Exception {
    super.setUp();
    getActivity();
}

public void testListGoesOverTheFold() {
    onView(withText("Hello world!")).check(matches(isDisplayed()));
}

}

这一行给我错误,我无法导入未找到的功能:

  

onView(withText(&#34; Hello world!&#34;))。check(matches(isDisplayed()));

我错过了什么吗?

2 个答案:

答案 0 :(得分:1)

手动调用gradle任务有时也会有所帮助。尝试从终端运行./gradlew assembleAndroidTest

答案 1 :(得分:0)

检查您是否在存储库部分添加了正确的maven存储库。这样的mavenCentral()mavenLocal()