Невозможно разрешить зависимости в Android Studio 3.2.1 - PullRequest
0 голосов
/ 14 января 2019

Мне не удается устранить ошибку зависимостей после обновления gradle до 5.1.1. Я перепробовал все возможные решения в этой теме , а также в этой версии . Но не смог решить мою проблему.

Это мой журнал ошибок:

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:design:28.0.0.
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test:runner:1.0.2.
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test.espresso:espresso-core:3.0.2.
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:design:28.0.0.
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support:design:28.0.0.
Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support:design:28.0.0.
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support:design:28.0.0.

А это уровень приложения build.gradle файл

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.project.FirstApplication"
        minSdkVersion 15
        targetSdkVersion 28
        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:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:28.0.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'
}

Это проект build.gradle

buildscript {

    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'


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

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

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

Привет

Ответы [ 3 ]

0 голосов
/ 15 января 2019

Вам нужно classpath 'com.android.tools.build:gradle:3.3.0', в соответствии с это для gradle 5.1.1.

Я не согласен с советами Дипака о том, чтобы ставить google() в последнюю очередь. Исторически мне это нужно сначала из-за других проблем.

Кроме того, ваш implementation 'com.android.support:appcompat-v7:28.0.0' является избыточным из-за уже имеющегося implementation 'com.android.support:design:28.0.0'.

Согласно это можно удалить

maven { url "https://maven.google.com" }

также.

0 голосов
/ 23 января 2019

Для меня причина была в том, что я работаю в запретной зоне. Так что была блокировка загружаемых файлов. И кое-как, как Gradle не смог загрузить все зависимости. Я просто запустил все в открытом интернет-соединении, и все это работает как шарм.

Итак, я следил за этим потоком , чтобы разрешить загрузку пакетов в ограниченной среде. Тем не менее, если это не помогло решить проблему, если вы работаете в ограниченной среде, обратитесь к сетевому парню.

0 голосов
/ 14 января 2019

В вашем проекте уровень Gradle изменить позицию Google (), как в моем примере.

buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.fabric.io/public'
        }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.google.gms:google-services:3.2.1'
        classpath 'io.fabric.tools:gradle:1.25.4'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...