无法解析 com.android.tools.build:gradle:3.3.2

Could not resolve com.android.tools.build:gradle:3.3.2

我试图将 firebase 身份验证添加到我的 android 项目中,但出现此错误。 我也尝试添加 'com.google.firebase:firebase-core:16.0.3',但它花了 40 多分钟,但仍然没有同步 gradle。

这是 build.gradle 文件:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "myaid.startup"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.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.google.firebase:firebase-auth:16.0.3'
    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'
}

这是app.gradle文件:

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

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath 'com.google.gms:google-services:4.1.0'

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

allprojects {
    repositories {
        google()
        jcenter()

    }
}

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

这是错误:

FAILURE: Build failed with an exception.

2 米 13 秒后配置失败错误:连接重置

我已经通过删除所有 .gradle 文件、SDK 文件、.m2 文件、.androidstudio 文件然后重新安装来解决了这个问题。

遵循了这个答案:

请检查您的 gradle 的代理设置。在以下文件中启用或禁用它:

~/.gradle/gradle.properties

喜欢:

systemProp.https.proxyPort=1080
systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyHost=127.0.0.1
systemProp.http.proxyPort=1080

建议:

  1. 如果您与存储库的连接不稳定,请使用代理 而不是直接连接。
  2. 如果您曾经使用代理 gradle,检查它是否还在工作。