当前位置: 首页 > 知识库问答 >
问题:

找不到android.arch.core:核心测试:2.1.0

戚晨
2023-03-14

运行测试时,我遇到以下错误:

无法解析配置的所有文件: app: dedegUnitTestCompileClasspath。找不到android.arch.core:核心测试:2.1.0。

如果有什么帮助的话,我正在使用Android Studio Arctic Fox | 2020.3。1金丝雀6

完整堆栈跟踪(屏幕截图,否则太长):

依赖项:

    implementation Dependencies.kotlin_standard_library
    implementation Dependencies.ktx

    implementation Dependencies.appcompat
    implementation Dependencies.constraint_layout
    implementation Dependencies.material
    implementation Dependencies.lifecycle_livedata
    implementation Dependencies.lifecycle_runtime
    implementation Dependencies.lifecycle_common_java8
    implementation Dependencies.lifecycle_viewmodel

    // Hilt
    implementation Dependencies.hilt_android
    kapt AnnotationProcessing.hilt_android_compiler
    implementation Dependencies.hilt_lifecycle_viewmodel
    kapt AnnotationProcessing.hilt_compiler

    // Coroutines
    implementation Dependencies.coroutines

    // Retrofit
    implementation Dependencies.retrofit
    implementation Dependencies.converter_gson
    implementation Dependencies.logging_interceptor

    // Glide
    implementation Dependencies.glide
    kapt AnnotationProcessing.glide_compiler

    // Navigation
    implementation Dependencies.navigation_fragment
    implementation Dependencies.navigation_ktx

    // PhotoView - Zooming ImageView
    implementation Dependencies.photo_view

    // Room
    implementation Dependencies.room_runtime
    kapt AnnotationProcessing.room_compiler
    implementation Dependencies.room_ktx

    // Compose
    implementation Dependencies.compose_runtime
    implementation Dependencies.compose_ui
    implementation Dependencies.compose_foundation
    implementation Dependencies.compose_foundation_layout
    implementation Dependencies.compose_material
    implementation Dependencies.compose_runtime_livedata
    implementation Dependencies.compose_ui_tooling
    implementation Dependencies.compose_material_theme_adapter

    // Test dependencies
    androidTestImplementation AndroidTestDependencies.junit_test_ext
    androidTestImplementation AndroidTestDependencies.espresso_core

    testImplementation TestDependencies.junit
    testImplementation TestDependencies.mockito_inline
    testImplementation TestDependencies.mockito_kotlin
    testImplementation TestDependencies.core_testing
    testImplementation TestDependencies.coroutines_test

Build.kt

object Build {
    const val build_tools = "com.android.tools.build:gradle:${Versions.gradle}"
    const val kotlin_gradle_plugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}"
    const val dagger_hilt_gradle = "com.google.dagger:hilt-android-gradle-plugin:${Versions.hilt}"
    const val navigation_safe_args_gradle = "androidx.navigation:navigation-safe-args-gradle-plugin:${Versions.navigation}"
}

依赖关系。kt

object Dependencies {
    const val kotlin_standard_library = "org.jetbrains.kotlin:kotlin-stdlib:${Versions.kotlin}"
    const val ktx = "androidx.core:core-ktx:${Versions.ktx}"
    const val appcompat = "androidx.appcompat:appcompat:${Versions.appcompat}"
    const val constraint_layout = "androidx.constraintlayout:constraintlayout:${Versions.constraintlayout}"
    const val hilt_android = "com.google.dagger:hilt-android:${Versions.hilt}"
    const val hilt_lifecycle_viewmodel = "androidx.hilt:hilt-lifecycle-viewmodel:${Versions.hilt_lifecycle_viewmodel}"
    const val coroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.coroutines_version}"
    const val room_runtime = "androidx.room:room-runtime:${Versions.room}"
    const val room_ktx = "androidx.room:room-ktx:${Versions.room}"
    const val retrofit = "com.squareup.retrofit2:retrofit:${Versions.retrofit2_version}"
    const val converter_gson = "com.squareup.retrofit2:converter-gson:${Versions.retrofit2_version}"
    const val logging_interceptor =
        "com.squareup.okhttp3:logging-interceptor:${Versions.okhttp_logging_interceptor}"
    const val glide = "com.github.bumptech.glide:glide:${Versions.glide_version}"
    const val material = "com.google.android.material:material:${Versions.material_design}"
    const val navigation_fragment =
        "androidx.navigation:navigation-fragment-ktx:${Versions.navigation}"
    const val navigation_ktx = "androidx.navigation:navigation-ui-ktx:${Versions.navigation}"
    const val photo_view = "com.github.chrisbanes:photoview:${Versions.photo_view}"
    const val lifecycle_livedata =
        "androidx.lifecycle:lifecycle-livedata-ktx:${Versions.lifecycle_version}"
    const val lifecycle_runtime =
        "androidx.lifecycle:lifecycle-runtime:${Versions.lifecycle_version}"
    const val lifecycle_common_java8 =
        "androidx.lifecycle:lifecycle-common-java8:${Versions.lifecycle_version}"
    const val lifecycle_viewmodel =
        "androidx.lifecycle:lifecycle-viewmodel-ktx:${Versions.lifecycle_version}"
    const val compose_runtime = "androidx.compose.runtime:runtime:${Versions.compose}"
    const val compose_ui = "androidx.compose.ui:ui:${Versions.compose}"
    const val compose_foundation = "androidx.compose.foundation:foundation:${Versions.compose}"
    const val compose_foundation_layout =
        "androidx.compose.foundation:foundation-layout:${Versions.compose}"
    const val compose_material = "androidx.compose.material:material:${Versions.compose}"
    const val compose_runtime_livedata =
        "androidx.compose.runtime:runtime-livedata:${Versions.compose}"
    const val compose_ui_tooling = "androidx.compose.ui:ui-tooling:${Versions.compose}"
    const val compose_material_theme_adapter =
        "com.google.android.material:compose-theme-adapter:${Versions.compose}"
}

测试依赖项。kt

object TestDependencies {
    const val junit = "junit:junit:${Versions.junit_4_version}"
    const val mockito_inline = "org.mockito:mockito-inline:${Versions.mockito_inline}"
    const val mockito_kotlin = "com.nhaarman.mockitokotlin2:mockito-kotlin:${Versions.mockito_kotlin}"
    const val core_testing = "android.arch.core:core-testing:${Versions.core_testing}"
    const val coroutines_test = "org.jetbrains.kotlinx:kotlinx-coroutines-test:${Versions.coroutines_version}"
}

AndroidTestDependencies。K

object AndroidTestDependencies {
    const val junit_test_ext = "androidx.test.ext:junit:${Versions.androidx_test_ext}"
    const val espresso_core = "androidx.test.espresso:espresso-core:${Versions.espresso}"
    const val instrumentation_runner = "androidx.test.runner.AndroidJUnitRunner"
}

注释处理。kt

object AnnotationProcessing {
    const val room_compiler = "androidx.room:room-compiler:${Versions.room}"
    const val hilt_compiler = "androidx.hilt:hilt-compiler:${Versions.hilt_compiler}"
    const val hilt_android_compiler = "com.google.dagger:hilt-android-compiler:${Versions.hilt}"
    const val glide_compiler = "com.github.bumptech.glide:compiler:${Versions.glide_version}"
}

版本。kt

object Versions {
    const val gradle = "7.0.0-alpha06"
    const val compilesdk = 30
    const val minsdk = 23
    const val targetsdk = 30
    const val kotlin = "1.4.30"
    const val room = "2.2.6"
    const val appcompat = "1.2.0"
    const val ktx = "1.3.2"
    const val hilt = "2.32-alpha"
    const val hilt_compiler = "1.0.0-alpha03"
    const val hilt_lifecycle_viewmodel = "1.0.0-alpha03"
    const val constraintlayout = "2.0.2"
    const val material_design = "1.2.1"
    const val photo_view = "2.0.0"
    const val espresso = "3.3.0"
    const val coroutines_version = "1.3.9"
    const val lifecycle_version = "2.3.0"
    const val retrofit2_version = "2.9.0"
    const val okhttp_logging_interceptor = "4.9.0"
    const val glide_version = "4.11.0"
    const val navigation = "2.3.2"
    const val junit_4_version = "4.13"
    const val androidx_test_ext = "1.1.2"
    const val mockito_inline = "3.1.0"
    const val mockito_kotlin = "2.2.0"
    const val core_testing = "2.1.0"
    const val compose = "1.0.0-alpha12"
}

共有1个答案

宗政卓
2023-03-14

android。arch是AndroidX之前体系结构组件的名称空间。在使用AndroidX项目时,需要使用AndroidX。拱核心这些依赖项的版本:

const val core_testing = "androidx.arch.core:core-testing:${Versions.core_testing}"
 类似资料:
  • 我刚刚开始使用CoreNLP版本3.6.0。我已经从这个网站下载了这个版本。使用命令行管道,我已经能够执行标准管道注释器,但是truecase注释器遇到了一个问题: 这是终端输出的副本: 有什么想法吗?

  • 运行后,它找不到我的ANDROID_SDK_ROOT 未定义$Android_SDK_ROOT,请将SDK安装目录的路径设置为$Android_SDK_ROOT, 它已经在我的/.zshrc文件中定义 导出Android_SDK=/users/chiwan/library/android/sdk导出路径=/users/chiwan/library/android/sdk/platform-tool

  • 我有一个Maven项目设置。在这个项目中,我使用JUnit进行单元测试。当我使用或运行测试时,不会运行任何测试。测试位于中,它们都以结束(它们匹配)。 这是我的pom.xml: 我的整个项目结构可以在这里看到:https://bitbucket.org/equator-lang/ppp4e/src/master/ 任何帮助都将非常感谢,因为我已经尝试了很多个小时来让这个工作,但不知道该做什么。 公

  • 我在测试一个android项目时遇到了麻烦。 我有一个没有源的调试apk。“开始activity”类是 我把它安装在 然后使用以下build.gradle和androidmanifest.xml创建一个新项目 null null 但当我运行测试时,它报告找不到“com.restfriedchicken.android.mainActivity”: 看来仪器没有成功?

  • 在我的asp.net核心项目(与2017年相比)中,我想运行我的测试方法,但在测试资源管理器中单击“运行所有”,我在测试资源管理器控制台中得到“最后一次测试运行不运行(总运行时间“布拉布拉”)”响应。我已经下载了我的NunitNuGet包。我认为在我的启动类或其他地方asp.net核心中测试有一些缺失的测试配置,或者一些缺失的NuGet包:/Thx提前给每个人。 这是我的测试课: 下面是我的“Gu

  • 问题内容: 我尝试使用Maven创建一个测试项目,并且单元测试工作正常。但是,当尝试对j2ee项目执行相同操作时,surefire无法找到单元测试。测试位于正确的目录(src / test / java)中,并且正在对其进行编译。 junit测试位于src / test / java / unit / TestAddition.java pom.xml中的surefire插件配置不包含/排除任何文