【问题标题】:Cannot resolve AndroidJunit4无法解析AndroidJunit4
【发布时间】:2018-11-27 16:38:57
【问题描述】:

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

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

这是我的 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'
}

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

有什么帮助吗?

【问题讨论】:

  • 不,同样的问题
  • 我没听懂,什么意思?
  • 添加了这些并且无法解析也导入 android.support.test.rule.ActivityTestRule;导入 android.support.test.runner.AndroidJUnit4;

标签: android gradle android-espresso


【解决方案1】:

按照以下步骤操作:

  • 为应用打开模块设置
  • 在 Dependencies 选项卡下,单击“+”并一一添加依赖项
  • 点击应用

这应该可行。

【讨论】:

    猜你喜欢
    • 2017-09-06
    • 2015-08-16
    • 2015-11-17
    • 2016-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多