相关疑难解决方法(0)

无法解析符号'AndroidJUnit4'

显然我需要正确的导入语句来解决这个问题.根据文档AndroidJUnit4,这应该是

import android.support.test.runner.AndroidJUnit4;
Run Code Online (Sandbox Code Playgroud)

当我这样做时,Android Studio突出显示runner为红色并抱怨"无法解析符号'跑步者'".

背景

我遵循Android开发者网站上的教程,使用UI Automator设置测试,从而达到了这一点.我遇到的第一个问题是,com.android.support:support-v4:22.2.0com.android.support.test:runner:0.2依赖于不同的版本com.android.support:support-annotations.我按照Android漏洞报告的建议,allprojects在我的项目中添加了以下内容build.gradle:

configurations.all {
    resolutionStrategy.force 'com.android.support:support-annotations:22.1.0'
}
Run Code Online (Sandbox Code Playgroud)

这解决了即时错误,但我怀疑它导致了我当前的问题.有没有人有任何关于如何解决这个问题的建议?

从`./gradlew:app:dependencies中重新发布部分

androidTestCompile - Classpath for compiling the androidTest sources.
+--- com.jayway.android.robotium:robotium-solo:5.2.1
+--- com.squareup:fest-android:1.0.8
|    \--- org.easytesting:fest-assert-core:2.0M10
|         \--- org.easytesting:fest-util:1.2.5
+--- com.android.support.test:runner:0.2
|    +--- junit:junit-dep:4.10
|    |    \--- org.hamcrest:hamcrest-core:1.1
|    +--- com.android.support.test:exposed-instrumentation-api-publish:0.2
|    \--- com.android.support:support-annotations:22.0.0 -> 22.2.0
+--- com.android.support.test:rules:0.2
|    \--- com.android.support.test:runner:0.2 (*)
\--- com.android.support.test.uiautomator:uiautomator-v18:2.1.0

compile - Classpath …
Run Code Online (Sandbox Code Playgroud)

android gradle build.gradle android-uiautomator testing-support-library

129
推荐指数
9
解决办法
6万
查看次数

在build.gradle中testImplementation和androidTestImplementation之间的android差异

我正在使用andorid studio 3.2,我是新手测试.我想添加一个测试库但是我没有得到我应该在依赖项部分testImplentationandroidTestImplementation中编写的内容.这两者有什么区别?

testing dependencies android gradle

28
推荐指数
2
解决办法
9133
查看次数

未解决的AndroidX参考ActivityTestRule

我正在尝试使用androidX espresso库通过工具测试来测试我的UI。在我的年级,我有:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'
apply plugin: "kotlin-kapt"

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "it.zehus.mybike"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        android.defaultConfig.manifestPlaceholders = ['appAuthRedirectScheme': 'net.openid.appauthdemo']
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    def lifecycle_version = "2.0.0"
    // ViewModel and LiveData
    implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"

    // room persistence library
    def room_version = "2.1.0-alpha04"
    implementation "androidx.room:room-runtime:$room_version"
    kapt "androidx.room:room-compiler:$room_version" // use …
Run Code Online (Sandbox Code Playgroud)

testing android kotlin android-espresso androidx

14
推荐指数
1
解决办法
3797
查看次数

无法解析符号AndroidJUnit4

我正在尝试为我的应用添加loginfacebook.但是当我添加一个需要这样做的存储库时.它导致了一个错误.AndroidJUnit4现在无法解决.

ExampleInstrumentedTest.java

package com.example.user.enyatravelbataan;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

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

import static junit.framework.Assert.assertEquals;
import static org.junit.Assert.*;

/**
 * Instrumentation test, which will execute on an Android device.
 *
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 */
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.example.user.enyatravelbataan", 
appContext.getPackageName());
}
}
Run Code Online (Sandbox Code Playgroud)

这是我的构建:gradle(app)

apply plugin: 'com.android.application'

 android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
useLibrary 'org.apache.http.legacy'


repositories {
    mavenCentral() …
Run Code Online (Sandbox Code Playgroud)

java junit4 facebook-login android-studio android-instrumentation

8
推荐指数
2
解决办法
1万
查看次数