简体   繁体   English

无法解析所有 androidx 库

[英]Failed to resolve all androidx libraries

I've added the library for the Room database.我已经为 Room 数据库添加了库。 It was a androidX library.这是一个 androidX 库。 I didn't know a lot about libraries (I am a beginner) and also didn't know about AndroidX.我不太了解库(我是初学者),也不了解 AndroidX。 I got these manifest merger errors and while resarching for a solution, I found out about the AndroidX libraries.我遇到了这些明显的合并错误,在研究解决方案时,我发现了 AndroidX 库。 So I wanted to migrate my project to AndroidX, but Android Studio can't resolve any of these libraries.所以我想将我的项目迁移到 AndroidX,但 Android Studio 无法解析任何这些库。

My build gradle(app):我的构建gradle(应用程序):

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.financetracker.financetracker"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    def room_version = "2.1.0-alpha04"
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0-beta01'
    implementation 'com.google.android.material:material:1.0.0-beta01'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
    implementation 'androidx.cardview:cardview:1.0.0-beta01'
    implementation "androidx.room:room-runtime:$room_version"
    annotationProcessor "androidx.room:room-compiler:$room_version"
}

My build gradle(Project):我的构建gradle(项目):

 buildscript {
        ext.kotlin_version = '1.3.21'
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.3.1'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        }
    }

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

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

My manifest:我的清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.financetracker.financetracker">

    <application
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar">
        <activity android:name=".ui.activities.SplashActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".ui.activities.HomeActivity" />
    </application>

</manifest>

Try adding these in your project build.gradle file,尝试将这些添加到您的项目build.gradle文件中,

buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.google.com' }
        mavenCentral()
    }
    ...
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.google.com' }
    }
}

For Kotlin DSL对于 Kotlin DSL

repositories {
    maven { setUrl("https://maven.google.com") }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何修复“错误:无法解析:androidx”? - How to fix 'ERROR: Failed to resolve: androidx'? 创建 androidx 项目后,Android gradle 无法立即解析核心 - Android gradle failed to resolve core right after creating a androidx project Gradle 无法解决:androidx.camera:camera2 - Gradle Failed to resolve : androidx.camera:camera2 错误:无法解析:androidx.appcompat:design:1.1.0 - ERROR: Failed to resolve: androidx.appcompat:design:1.1.0 迁移到 AndroidX 后,如何更新所有库? - How do I update all libraries, after Migrating to AndroidX? 无法添加依赖:无法解决:androidx.lifecycle:lifecycle-extensions:2.2.0-rc2 - Unable to add dependency: Failed to resolve: androidx.lifecycle:lifecycle-extensions:2.2.0-rc2 错误:无法解析:androidx.support:support-v7:28.0.0 Android Studio - ERROR: Failed to resolve: androidx.support:support-v7:28.0.0 Android Studio 错误:无法解决:androidx.annotation.annotation:1.1.0:受影响的模块:app - ERROR: Failed to resolve: androidx.annotation.annotation:1.1.0: Affected Modules: app 解析失败:androidx.exifinterface:exifinterface:1.3.5 添加 Google Maven 存储库 - Failed to resolve: androidx.exifinterface:exifinterface:1.3.5 Add Google Maven repository FragmentManager 无法在 androidx 中解析 - FragmentManager can't resolve in androidx
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM