无法解析AndroidJunit4

时间:2018-06-18 19:18:15

标签: android gradle android-espresso

我已经在论坛上搜索过这个问题,解决方案似乎对我没什么帮助。它们都涉及将我的测试移到androidTest,我有

这是我的文件夹结构的图片

enter image description here

这是我的build.gradle

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        jcenter()
        mavenCentral()
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
        classpath "com.newrelic.agent.android:agent-gradle-plugin:5.+"
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'newrelic'

repositories {
    jcenter()

    flatDir {
        dirs '../../xxx-native-app-android/trunk/baseline/UrbanAirshipLib/aars'
    }

    maven { url 'https://maven.fabric.io/public' }
    mavenCentral()
}


android {
    useLibrary 'org.apache.http.legacy'
    signingConfigs {
        config {
            keyAlias 'xxxkey'
            keyPassword ''
            storeFile file('../app/key/xxx_key.jks')
            storePassword ''
        }
    }

    compileSdkVersion 26
    buildToolsVersion '26.0.0'
    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 26
//        signingConfig signingConfigs.gtn
        signingConfig signingConfigs.config
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
        xxx {
            applicationId "com.bluestem.xxx.android"
            // both flavor should have same version and incremental
            versionCode 66
            versionName "1.1.3"
//            signingConfig signingConfigs.gtn
        }
        yyy {
            applicationId "com.bluestem.yyy.android"
            versionCode 21
            versionName "1.1.3"
//            signingConfig signingConfigs.gtn
        }
    }
    lintOptions {
        abortOnError false
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile project(path: ':custompin', configuration: 'default')
    compile project(path: ':view_pager_indicator_lib', configuration: 'default')
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:support-v4:26.1.0'
    compile 'com.android.support:support-v13:26.1.0'
    compile 'com.android.support:recyclerview-v7:26.1.0'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'com.google.android.gms:play-services-gcm:7.0.0'
    compile 'com.squareup.okhttp:okhttp:2.7.5'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.joooonho:selectableroundedimageview:1.0.1'
    compile 'com.joanzapata.pdfview:android-pdfview:1.0.4@aar'
    compile 'de.greenrobot:eventbus:2.4.0'
    compile 'com.urbanairship:urbanairship-lib:6.0.2@aar'
    compile 'org.parceler:parceler-api:1.0.1'
    compile 'com.wdullaer:materialdatetimepicker:1.4.2'
    compile 'com.newrelic.agent.android:android-agent:5.+'
    annotationProcessor "org.parceler:parceler:1.0.1"
    compile('com.crashlytics.sdk.android:crashlytics:2.5.6@aar') {
        transitive = true;
    }

    // https://mvnrepository.com/artifact/com.android.support.test/runner
    androidTestCompile 'com.android.support:support-annotations:26.1.0'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'
    androidTestCompile 'com.android.support.test:runner:0.5'
    androidTestCompile 'com.android.support.test:rules:0.5'
    androidTestCompile 'junit:junit:4.12'
    androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
}

我已经尝试了所有我能想到的东西,重建项目,不同版本的一切......

任何帮助?

1 个答案:

答案 0 :(得分:0)

请按照以下步骤操作:

  • 打开应用程序的模块设置
  • 在“依赖关系”选项卡下,单击“+”并逐个添加依赖关系
  • 点击“应用”

这应该有用。