【问题标题】:What is error package android x and Android J Unit 4?什么是错误包 android x 和 Android J Unit 4?
【发布时间】:2019-10-06 18:01:44
【问题描述】:

我写了一个示例代码并收到了这些错误。

错误:找不到符号类 Android J Unit 4。

错误:package android x test ext j unit runners 不存在

我安装了最新版本的 android studio,在运行每个代码后,我收到了这些错误。

这些错误是什么意思?

代码:

package com.example.hello;

public class JavaBasics {
    public static void main(String args[]){
        System.out.println("Hello World");
    }
}

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.hello"
        minSdkVersion 14
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

【问题讨论】:

  • 您好,请问您可以添加您的应用模块 build.gradle 文件吗?
  • 嗨。我为模块 build.gradle 文件添加了更多截图
  • 新图片上传

标签: android package


【解决方案1】:

我解决了.. 我必须使用

@RunWith(AndroidJUnit4.class)

在 . java和

androidTestImplementation 'androidx.test.ext:junit:1.1.1'

在应用程序中(build.grade)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-14
    • 2016-05-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多