我昨天更新了Gradle插件,现在android studio无法构建我的应用了。该应用程序显示以下错误。
ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve io.grpc:grpc-core:[1.16.1].
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve io.grpc:grpc-core:[1.16.1].
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve io.grpc:grpc-core:[1.16.1].
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve io.grpc:grpc-core:[1.16.1].
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve io.grpc:grpc-core:[1.16.1].
Show Details
Affected Modules: app
WARNING: API 'variant.getExternalNativeBuildTasks()' is obsolete and has been replaced with 'variant.getExternalNativeBuildProviders()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getExternalNativeBuildTasks(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
Affected Modules: app
我的应用程序级别build.gradle文件如下:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.mvp1stockmeter"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
dataBinding
{
enabled true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4: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'
implementation 'com.android.support:multidex:1.0.3'
implementation 'org.jsoup:jsoup:1.11.3'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-firestore:18.0.0'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9'
implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
implementation 'com.google.firebase:firebase-auth:16.1.0'
//implementation 'com.facebook.android:facebook-android-sdk:4.x'
implementation 'com.jjoe64:graphview:4.2.2'
}
apply plugin: 'com.google.gms.google-services'
我的项目级别的build.gradle文件如下:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'io.fabric.tools:gradle:1.26.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
}
我也在StackOverflow和google上进行了搜索。但是没有找到任何信息。请帮忙。我被困在这里。
答案 0 :(得分:1)
在项目级别build.gradle文件的allprojects {}部分中添加mavenCentral()已为我解决了此问题。
答案 1 :(得分:0)
删除此行:-testInstrumentationRunner“ android.support.test.runner.AndroidJUnitRunner” ...对我有用
答案 2 :(得分:0)
在项目级别build.gradle文件的buildScript {}部分中添加mavenCentral()已为我解决了此问题。感谢您的支持。
答案 3 :(得分:0)
我不知道为什么会这样,但是自从昨天(2019年3月21日)以来一直在发生。我认为这是Maven存储库中的问题吗?因为android studio尝试获取该库的网址已关闭。
无论如何,解决方法是“手动”将AS指向缺少的依赖项,并将此行添加到build.gradle的依赖项中{...}
implementation group: 'io.grpc', name: 'grpc-core', version: '1.16.1'
然后同步,然后您可以删除该行。
好吧,我希望有人能解释发生了什么事。
答案 4 :(得分:0)
我遇到了以下三种类型的构建错误:
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve io.grpc:grpc-core:[1.28.0].
与许多与android studio相关的问题一样,
File -> Invalidate Caches / Restart...
是我的把戏。
答案 5 :(得分:0)
将mavenCentral()添加到buildscripts->存储库和allprojects->存储库中,并同步项目。