繁体   English   中英

无法解析外部依赖项 com.google.gms:google-services:4.2.0,因为没有定义存储库。 安卓工作室 3.5

[英]Cannot resolve external dependency com.google.gms:google-services:4.2.0 because no repositories are defined. Android Studio 3.5

无法解析外部依赖项 com.google.gms:google-services:4.2.0,因为没有定义存储库。

我从 Stack Overflow 尝试了很多解决方案,但没有一个我提到的解决方案对我有用

这是我的项目级别 build.gradle

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'
        classpath 'com.google.gms:google-services:4.2.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
}

这是我的应用程序级 build.gradle

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

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.rsolveapp"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility = '1.8'
        targetCompatibility = '1.8'
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.firebase:firebase-auth:16.0.4'
    implementation 'com.google.firebase:firebase-database:16.0.4'
    implementation 'com.google.firebase:firebase-storage:16.0.4'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
    implementation 'androidx.annotation:annotation:1.1.0'
    implementation 'com.google.firebase:firebase-analytics:17.0.1'
}

buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:4.2.0'
    }
}

程序同步后,它给了我这个错误“无法解析外部依赖 com.google.gms:google-services:4.2.0,因为没有定义存储库。”

我遇到了类似的问题,我通过添加解决了它,

repositories {
        google()
        jcenter()
    }

的build.gradle(模块:应用程序)buildscript文件。 祝你今天过得愉快

尝试在“应用”级别的 gradle 文件中添加以下内容

repositories {
    mavenCentral()
}

在 build.gradle 应用程序级别添加以下代码段

repositories {
    google()
    jcenter()
}

例如

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.google.gms:google-services:4.3.3'
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM