![](/img/trans.png)
[英]Unable to resolve dependencies with Android Studio and Firebase
[英]Unable to resolve dependencies in Android Studio 3.2.1
將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.
這是app level 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
}
問候
在您的項目級別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
}
}
你需要classpath 'com.android.tools.build:gradle:3.3.0'
gradle:3.3.0 classpath 'com.android.tools.build:gradle:3.3.0'
,根據這個對於gradle 5.1.1
。
我不同意Deepak最后提出google()
提示。 從歷史上看,由於其他問題,我首先需要它。
此外,您的implementation 'com.android.support:appcompat-v7:28.0.0'
是冗余的,因為已經implementation 'com.android.support:design:28.0.0'
。
根據這個你可以刪除
maven { url "https://maven.google.com" }
同樣。
對我來說,原因是我在禁區工作。 因此阻止了正在下載的文件。 還有一些gradle無法下載所有依賴項。 我只是在開放的互聯網連接中運行一切,它們都像魅力一樣。
所以我遵循這個線程允許在受限制的環境中下載包。 如果您在受限制的環境中工作仍然無法解決您的問題,請聯系您的網絡人員。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.