【问题标题】:i can't install androidx.preference library我无法安装 androidx.preference 库
【发布时间】:2020-02-25 14:37:31
【问题描述】:

我想从 androidx 安装偏好库。当我去项目结构添加这个库时: 1.我没有1.1.0版本。我只有 1.1.0-alpha05 和 1.0.0 版本。 2.当我想安装这个库的任何版本时,我得到: 错误:无法解决:androidx.preference:preference:VERSION

** 我对其他库没有同样的问题

这是我的 gradle (app) 模块:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.notebook_v2"
        minSdkVersion 19
        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.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'androidx.appcompat:appcompat:1.0.2'

}

这是 gradle(project) 模块:

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

buildscript {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }


    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'

        // 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
}

【问题讨论】:

  • 尝试使用低版本的库,android studio 建议您使用最新的稳定可用版本。你也可以查看androidX releases here的版本

标签: android gradle installation project-structure


【解决方案1】:

尝试实现这个

implementation 'androidx.preference:preference:1.1.0'

也许您需要更新构建工具

【讨论】:

    猜你喜欢
    • 2019-11-30
    • 1970-01-01
    • 2021-05-17
    • 2020-12-06
    • 2021-12-30
    • 1970-01-01
    • 1970-01-01
    • 2015-08-20
    • 2021-01-24
    相关资源
    最近更新 更多