簡體   English   中英

gradle 插件更新后,Android Studio 無法構建我的應用程序

[英]Android studio unable to build my app after gradle plugin updated

我昨天更新了 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 上搜索過這個。 但是沒有找到任何資料。 請幫忙。 我被困在這里。

我不知道為什么會發生這種情況,但它從昨天,即 2019 年 3 月 21 日開始發生。我認為這是 Maven 存儲庫中的問題? 因為 android studio 試圖獲取該庫的 url 已關閉。

無論如何,解決方法是“手動”將 AS 指向缺少的依賴項,將此行添加到 build.gradle 中的依賴項{...}

implementation group: 'io.grpc', name: 'grpc-core', version: '1.16.1'

然后同步,然后您可以刪除該行。

好吧,我希望有人能解釋發生了什么。

將 mavenCentral() 添加到項目級 build.gradle 文件的 allprojects{} 部分已經為我解決了這個問題。

將 mavenCentral() 添加到項目級 build.gradle 文件的 buildScript{} 部分已經為我解決了這個問題。 謝謝您的支持。

我有以下類型的三個構建錯誤:

Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve io.grpc:grpc-core:[1.28.0].

與許多與 android studio 相關的問題一樣,

File -> Invalidate Caches / Restart...

幫我解決了這個問題。

刪除這一行:- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"...它對我有用

將 mavenCentral() 添加到您的 buildscripts->repositories 和 allprojects->repositories 並同步項目。

暫無
暫無

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

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