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

找不到Android . arch . navigation:navigation-safe-args-grad le-plugin:2 . 3 . 5。?

常英毅
2023-03-14

我正在使用Android导航组件,但它给出了一个错误 配置根项目“Android编码挑战”时出现问题。

无法解析配置“:类路径”的所有工件。找不到android.arch.navigation:navigation-safe-args-gradle-plugin:2.3.5。在以下位置搜索:

在我app.gradle

plugins {
    id 'com.android.application'
    id 'kotlin-android'
}
apply plugin: 'androidx.navigation.safeargs.kotlin'
apply plugin: 'kotlin-kapt'
apply from: '../commons.gradle'

android {
    compileSdkVersion 30
    buildFeatures {

        dataBinding = true

        // for view binding:
        // viewBinding = true
    }

    buildToolsVersion "29.0.3"

    defaultConfig {
        applicationId "com.example.androidcodingchallenge"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables{
            useSupportLibrary = true
        }

        multiDexEnabled true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8.toString()
    }
}

dependencies {
    implementation project(':data')
    implementation project(':domain')
    implementation project(':presentation')
    implementation project(':remote')
    implementation project(':cache')
    implementation project(':common')
    implementation project(':device')

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation "com.google.android.material:material:$material_version"

    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'

    implementation 'androidx.cardview:cardview:1.0.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    //navigation component
//    implementation "androidx.navigation:navigation-fragment-ktx:2.3.2"
//    implementation "androidx.navigation:navigation-ui-ktx:2.3.2"

    // UI
    implementation "com.github.bumptech.glide:glide:$glide_version"
    kapt "com.github.bumptech.glide:compiler:$glide_version"

    // Ktx
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.3.0"
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0'
    implementation "androidx.fragment:fragment-ktx:1.3.0"

    // Navigation
    implementation "android.arch.navigation:navigation-fragment-ktx:$version_navigation"
    implementation "android.arch.navigation:navigation-ui-ktx:$version_navigation"

    //viewpager2
    implementation "androidx.viewpager2:viewpager2:1.0.0"

    implementation 'com.thoughtbot:expandablerecyclerview:1.3'
    implementation 'com.thoughtbot:expandablecheckrecyclerview:1.4'

    //indicator
    implementation 'me.relex:circleindicator:2.1.4'
    //lottie
    implementation "com.airbnb.android:lottie:3.4.1"
    //datastore
    implementation "androidx.datastore:datastore-preferences:1.0.0-alpha06"

    implementation 'androidx.hilt:hilt-navigation-fragment:1.0.0-alpha03'

    //LeakCanary
    debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakcanary_version"

    //Retrofit
    implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
    implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
    implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'

    //multidex
    implementation 'com.android.support:multidex:1.0.3'

}

在我的共享资源下面。

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'dagger.hilt.android.plugin'

androidExtensions {
    experimental = true
}

android {
//    compileSdkVersion Versions.compileSdkVersion
//    buildToolsVersion Versions.buildTool
//    defaultConfig {
//        minSdkVersion Versions.minSdk
//        targetSdkVersion Versions.targetSdk
//        versionCode Releases.versionCode
//        versionName Releases.versionName
//        vectorDrawables.useSupportLibrary = true
//    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    kapt {
        javacOptions {
            // Increase the max count of errors from annotation processors.
            // Default is 100.
            option("-Xmaxerrs", 500)
        }
        // Configure kapt to correct error types for Hilt
        correctErrorTypes true
    }

    buildFeatures{
        dataBinding = true
    }

    kotlinOptions {
        jvmTarget = "1.8"
    }

    lintOptions {
        abortOnError false
    }

    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
}

dependencies {
    //Loads packaged libraries in the libs folder
    implementation fileTree(dir: 'libs', include: ['*.jar'])

//    implementation KotlinLibraries.kotlin
//    implementation AndroidLibraries.coreKtx
//
//    implementation Libraries.hilt
//    implementation Libraries.hiltJetpack
//    kapt Libraries.hiltCompiler
//    kapt Libraries.hiltJetpackCompiler
//
//    // For instrumentation tests
//    androidTestImplementation Libraries.hiltAndroidTest
//    kaptAndroidTest Libraries.hiltAndroidTestCompiler
//
//    // For local unit tests
//    testImplementation Libraries.hiltAndroidUnitTest
//    kaptTest Libraries.hiltAndroidUnitTestCompiler
//
//    implementation TestLibraries.androidTestRunner
//    implementation TestLibraries.junit
//    implementation TestLibraries.espresso
//    implementation TestLibraries.espressoContrib

    // Concurrency
    implementation "io.reactivex.rxjava2:rxkotlin:$rxkotlin_version"
    implementation "io.reactivex.rxjava2:rxandroid:$rxandroid_version"


    //Hilt
    implementation "com.google.dagger:hilt-android:$hilt_version"
    kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
    implementation "androidx.hilt:hilt-lifecycle-viewmodel:$hilt_androidx_version"
    kapt "androidx.hilt:hilt-compiler:$hilt_androidx_version"

    // Utils
    implementation "com.jakewharton.threetenabp:threetenabp:$threetenabp_version"


}

低于构建。gradle我已经声明了构建路径

buildscript {
    ext{
        kotlin_version = "1.4.20"
        version_navigation = "2.3.5"
        hilt_version = '2.31.2-alpha'

        version_navigation = "2.3.5"
        version_lifecycle_extensions = "2.2.0"
        lifecycle_version = "2.2.0"
        hilt_androidx_version = "1.0.0-alpha03"

        material_version = "1.3.0"

        coroutines_version = "1.4.1"

        junit_version = "4.13"

        retrofit_version = "2.9.0"
        okHttp_version = "4.9.0"
        moshi_converter_version = '2.9.0'
        moshi_version = '1.11.0'

        mockwebserver_version = "4.9.0"
        robolectric_version = "4.4"
        mockito_version = "3.5.15"
        google_truth_version = "1.0"
        coroutines_test = "1.3.1"

        room_version = "2.3.0"

        threetenabp_version = "1.2.4"
        leakcanary_version = "2.4"
        timber_version = "4.7.1"

        glide_version = "4.11.0"
        androidsvg_version = "1.4"

        rxkotlin_version = "2.4.0"
        rxandroid_version = "2.1.1"

        google_services_version = "4.3.8"
    }

    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.1"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
        classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:$version_navigation"

        classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"

        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        classpath "com.google.gms:google-services:$google_services_version"
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        flatDir {
            dirs 'libs'
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我尝试过以下答案找不到androidx.navigation:safe-args-gradle-plugin:1.0.0-alpha01,它没有帮助我想知道我错过了什么

共有1个答案

鞠宏恺
2023-03-14

您正在使用android.arch。navigation,它不是AndroidX版本的navigation。您需要用androidx替换每一个。导航根据声明依赖项文档

classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$version_navigation"

同样,您的依赖关系也是如此:

// Navigation
implementation "androidx.navigation:navigation-fragment-ktx:$version_navigation"
implementation "androidx.navigation:navigation-ui-ktx:$version_navigation"
 类似资料:
  • 我想使用导航架构组件。 项目:Build.Gradle 模块:Build.Gradle

  • 在以下任何源中未找到插件[id:'gradle.Plugin.com.onesignal.onesignal gradle Plugin']: Gradle Core插件(插件不在'org.gradle'命名空间) 插件库(插件依赖必须包括此源的版本号) 我的身材。格拉德尔: 我正在使用android studio Arctic 2020.3.1。渐变7.0.2

  • 构建失败,类路径错误: : 构建文件是工作构建的直接副本。上下文是从Kotlin脚本Gradle开始的。据我所知,这个剧本应该不错。 请注意,我没有使用intelli-J,这完全是使用Kotlin脚本Gradle的CLI。 也许这很简单,比如“插件”和“插件”。。。

  • 我正在学习Selenium,我想尝试将maven-compiler-plugin添加到pom.xml并重新导入maven设置。因此,我找到了这个例子来做它http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html,并尝试将代码添加到pom.xml。但是示例3.8

  • 问题内容: 我将Javadoc doclet与gradle一起使用,因此需要使用package.tools.jar包,它位于jdk的lib文件夹中(本例中为1.6.0_26)。 关键是gradle不会自动获取它,因此我将那个工具包添加到我的libs文件夹中,然后将其添加到dependencies.gradle。 现在,我想直接从JDK主页将其带入我的dependencies.gradle。有没有办

  • 我创建了一个具有以下配置的gradle项目: 当我执行“gradle build”时,出现以下错误消息: 找不到系统Java编译器。确保安装了JDK(不仅仅是JRE),并配置了JAVA_HOME系统变量以指向相应的目录。 这很奇怪,因为我有$JAVA_HOME set: