簡體   English   中英

如何修復“錯誤:無法解析:androidx”?

[英]How to fix 'ERROR: Failed to resolve: androidx'?

我重新開始工作以完成我的申請,但是當應用程序開始同步時,它給了我

無法解決:androidx Affected Modules: href="openFile:D:/.android/Step View/Application/Source Code/app/build.gradle">app

我看到一個這樣的問題,但它對我不起作用。 對不起,我的英語不好。

這是我的畢業證書。 應用程序

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' }
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.11.0, 0.99.99]'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

repositories {
    maven {
        url 'https://maven.google.com'
    }
}

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.xcoder.stepview"
        minSdkVersion 17
        targetSdkVersion 28
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.connection_light.runner.AndroidJUnitRunner"
        manifestPlaceholders = [
                onesignal_app_id               : '6a2c7692-81ec-4d12-b973-6b78f71f380e',
                // Project number pulled from dashboard, local value is ignored.
                onesignal_google_project_number: 'REMOTE'
        ]
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    buildToolsVersion '28.0.3'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
    implementation 'com.google.firebase:firebase-core:16.0.6'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.github.kittinunf.fuel:fuel-android:1.12.1'
    implementation 'com.google.firebase:firebase-ads:17.1.2'
    implementation 'com.github.bassaer:chatmessageview:1.10.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
    implementation 'com.github.markushi:circlebutton:1.1'
    implementation 'com.google.android.material:material:1.1.0-alpha02'
    implementation 'com.google.firebase:firebase-database:16.0.5'
    implementation 'com.github.ybq:Android-SpinKit:1.2.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'commons-io:commons-io:2.5'
    implementation 'androidx.percentlayout:percentlayout:1.0.0'
    implementation 'com.onesignal:OneSignal:[3.9.1, 3.99.99]'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.connection_light:runner:1.1.1'
    androidTestImplementation 'androidx.connection_light.espresso:espresso-core:3.1.1'
}

apply plugin: 'com.google.gms.google-services'

嘗試將所有 com.android* 更新為可用的 com.androidx* 版本。

確保你有...

android.enableJetifier=true
android.useAndroidX=true

添加到您的 gradle.properties。

或者你可以這樣做

With Android Studio 3.2 and higher, you can quickly migrate an existing project 
to use AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.

https://developer.android.com/jetpack/androidx/migrate

您在一個項目中同時使用support libraryandroidx library ,這就是問題所在。

將支持庫更改為首選的AndroidX庫。

你也可以從 Android Studio 本身遷移到 AndroidX

只需轉到重構 > 遷移到 AndroidX > 遷移

gradle.properties文件中添加以下代碼

android.enableJetifier=true
android.useAndroidX=true

有關遷移的更多信息,請檢查

就我而言,它是由build.gradle的拼寫錯誤引起的:

//androidTestImplementation 'androidx  .test.espresso:espresso-core:3.2.0' // wrong!
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

我通過使用 stacktrace 選項從命令行運行 Gradle 包裝器發現了錯誤:

./gradlew clean build --stacktrace

輸出:

引起:org.gradle.internal.resolve.ModuleVersionNotFoundException:找不到androidx。 test.espresso:espresso-core:3.2.0。

對我來說是

implementation 'androidx.appcompat:appcompat:1.1.0'

這必須是

implementation 'androidx.appcompat:appcompat:1.3.0-alpha01'

這意味着檢查版本並為您擁有的每個 androidx 實現最后一個版本。

你最升級所有基礎庫

更改

    implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'

    implementation 'androidx.appcompat:appcompat:1.+'

 androidTestImplementation 'androidx.connection_light:runner:1.1.1'

 androidTestImplementation 'androidx.test:runner:1.+'

 androidTestImplementation 'androidx.connection_light.espresso:espresso-core:3.1.1'

androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM