ОШИБКА: невозможно разрешить зависимость в Android Studio 3.4

Я использовал Android Studio 3.3, и все работало нормально. Но сегодня после обновления до 3.4 я получаю эти ошибки. Кажется, проблема связана с зависимостями androidX. Это также происходит в двух моих разных проектах, которые зависят от androidX.

Я пробовал следующее:

1. Очистите и перестройте мой проект

2. Сделайте недействительным кеш и перезапустите.

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.cursoradapter:cursoradapter:1.0.0.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.drawerlayout:drawerlayout:1.0.0.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.cursoradapter:cursoradapter:1.0.0.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.drawerlayout:drawerlayout:1.0.0.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.cursoradapter:cursoradapter:1.0.0.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.drawerlayout:drawerlayout:1.0.0.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve androidx.cursoradapter:cursoradapter:1.0.0.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve androidx.drawerlayout:drawerlayout:1.0.0.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve androidx.cursoradapter:cursoradapter:1.0.0.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve androidx.drawerlayout:drawerlayout:1.0.0.
Show Details
Affected Modules: app

Мой build.gradle (приложение)

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: "androidx.navigation.safeargs"
apply plugin: 'com.apollographql.android'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "********"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0-alpha04'
    implementation 'com.google.android.material:material:1.1.0-alpha05'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha4'
    implementation 'androidx.vectordrawable:vectordrawable:1.1.0-alpha01'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0-alpha04'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'

    //Apollo
    implementation 'com.apollographql.apollo:apollo-runtime:1.0.0-alpha5'
    implementation 'com.apollographql.apollo:apollo-http-cache:1.0.0-alpha5'
    implementation "com.apollographql.apollo:apollo-coroutine-support:1.0.0-alpha5"

    //okhttp3
    implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'

    //Anko
    implementation "org.jetbrains.anko:anko:$anko_version"
    implementation "org.jetbrains.anko:anko-design:$anko_version"

    //Dependency injection
    implementation 'com.google.dagger:dagger:2.16'
    kapt 'com.google.dagger:dagger-compiler:2.16'

    //Room
    implementation "androidx.room:room-runtime:2.1.0-alpha06"
    implementation "androidx.room:room-coroutines:2.1.0-alpha04"
    kapt "androidx.room:room-compiler:2.1.0-alpha06"

    implementation "androidx.lifecycle:lifecycle-extensions:2.1.0-alpha04"
    implementation "androidx.paging:paging-runtime-ktx:2.1.0"

    //Coroutines
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
    implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2'

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

    //Fresco - Image Loader.
    implementation 'com.facebook.fresco:fresco:1.12.1'

    //Maps and Location
    implementation "com.google.android.gms:play-services-location:16.0.0"
    implementation "com.google.android.gms:play-services-maps:16.1.0"

    //Preference
    implementation "androidx.preference:preference:1.0.0"

    //Multidex
    implementation 'androidx.multidex:multidex:2.0.1'

    //Google Ads
    implementation 'com.google.android.gms:play-services-ads:17.2.0'

    //ImagePicker.
    implementation 'com.github.nguyenhoanglam:ImagePicker:1.3.1'
}

уровень проекта build.gradle

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

buildscript {
    ext {
        anko_version = '0.10.8'
        kotlin_version = '1.3.30'
    }

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0"
        classpath 'com.apollographql.apollo:apollo-gradle-plugin:1.0.0-alpha5'

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

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
        maven { //For coroutine support
            url 'http://dl.bintray.com/apollographql/android'
        }
    }
}

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

Как я могу это решить

Это может произойти из-за многих проблем. 1. Проверьте конфигурацию вашей сети, возможно, ваша сеть находится под конфигурацией прокси-сервера. 2. Откройте новый проект, а не существующий, тогда все будет правильно скомпилировано, затем настройте свои старые проекты на основе успешно построенного проекта. 3. Отключите автономный режим, если он включен. 4. Также ответом может быть хорошее сетевое соединение. попробуйте их один за другим. Так как это случается со мной часто, и один из вышеперечисленных методов всегда помогал мне. BWT не забывайте "SYNC Project" после каждого шага

Jasurbek 21.04.2019 12:40

вы должны добавить android.enableJetifier=true android.useAndroidX=true эти правила в файл gradle.properties в вашем проекте

madhu s 21.04.2019 13:15

У меня те же проблемы при попытке преобразовать мгновенное приложение старого стиля в новые динамические модули. это происходит в установленной функции. должна быть ошибка в gradle. дерьмовая реализация это

Gillis Haasnoot 07.05.2019 17:09

@GillisHaasnoot решил это?

Nux 07.05.2019 17:12

Да, я немного дальше. Моя проблема заключалась в том, что я не включал основную библиотеку Android X в динамический модуль, где я получил ошибки. Поэтому я создал отдельную «Библиотеку» (не динамический модуль), где у меня есть все основные зависимости, такие как: androidx.core:core:1.1.0-alpha05 androidx.fragment:fragment:1.1.0-alpha07 com.google .firebase:firebase-core:16.0.8 и т. д. Я включаю эту библиотеку во все свои динамические модули. Сейчас хоть строит. Конечно, теперь я столкнулся с новым набором совершенно других проблем, которые мне нужно решить :)

Gillis Haasnoot 08.05.2019 15:58

У меня такая же проблема при обновлении до gradle 5.1.1. Очистка кеша не работает

ScruffyFox 10.07.2019 12:43
8
6
21 619
2
Перейти к ответу Данный вопрос помечен как решенный

Ответы 2

Добавьте следующее в список зависимостей вашего модуля приложения.

implementation 'androidx.drawerlayout:drawerlayout:1.0.0-alpha1'
implementation 'androidx.cursoradapter:cursoradapter:1.0.0-alpha1'

Спасибо за ответ. Я добавил эти зависимости, но все равно сталкиваюсь с той же проблемой.

Nux 22.04.2019 15:38
Ответ принят как подходящий

Я решил свою проблему, изменив URL-адрес дистрибутива на gradle-wrapper.properties.

от

distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

вернуться к

distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

А также отмена зависимости gradle в build.gradle от

classpath 'com.android.tools.build:gradle:3.4.0'

вернуться к

classpath 'com.android.tools.build:gradle:3.3.2'

И теперь мой проект в порядке.

Но удалось ли решить проблему без понижения версии?

Dr.jacky 08.05.2019 13:39

@ Dr.jacky Я много пробовал и потерпел неудачу. Я жду следующего выпуска Gradle, возможно, в нем есть ошибки!

Nux 08.05.2019 14:06

Жду ответа здесь: stackoverflow.com/questions/55782093/…

Dr.jacky 08.05.2019 15:12

Со мной случилось то же самое. Исправлено путем обновления каждой библиотеки до последней версии.

APP Bird 28.06.2020 16:39

Другие вопросы по теме