0

我正在尝试在架构组件中安装最新版本的导航。我正在关注此文档教程链接

当我尝试同步时,它给出了错误。

Could not find androidx.navigation:safe-args-gradle-plugin:1.0.0-alpha01.
Searched in the following locations:
    https://dl.google.com/dl/android/maven2/androidx/navigation/safe-args-gradle-plugin/1.0.0-alpha01/safe-args-gradle-plugin-1.0.0-alpha01.pom
    https://dl.google.com/dl/android/maven2/androidx/navigation/safe-args-gradle-plugin/1.0.0-alpha01/safe-args-gradle-plugin-1.0.0-alpha01.jar
    https://jcenter.bintray.com/androidx/navigation/safe-args-gradle-plugin/1.0.0-alpha01/safe-args-gradle-plugin-1.0.0-alpha01.pom
    https://jcenter.bintray.com/androidx/navigation/safe-args-gradle-plugin/1.0.0-alpha01/safe-args-gradle-plugin-1.0.0-alpha01.jar
Required by:
    project :

模块摇篮

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.ard.navigationapp"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'


    def nav_version = "1.0.0-alpha01"
    implementation 'android.arch.navigation:navigation-fragment:$nav_version' // use -ktx for Kotlin
    implementation 'android.arch.navigation:navigation-ui:$nav_version' // use -ktx for Kotlin

    // optional - Test helpers
    androidTestImplementation 'android.arch.navigation:navigation-testing:$nav_version' // use -ktx for Kotlin

}

apply plugin: 'androidx.navigation.safeargs'

项目 Gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'

        classpath "androidx.navigation:safe-args-gradle-plugin:1.0.0-alph

a01"

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

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

2 回答 2

3

根据目前https://maven.google.com中的内容,该工件似乎不存在。试试android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha01吧。另请参阅此问题

于 2018-05-13T17:10:29.163 回答
1

尝试添加

classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha01"

代替

classpath "androidx.navigation:safe-args-gradle-plugin:1.0.0-alpha01"

如果你不关心参数的类型安全,你可以跳过安全参数部分,你会很好地使用导航组件。

于 2018-05-14T10:47:53.507 回答