当前位置: 首页 > 知识库问答 >
问题:

使用google play-services-maps 11.6.2时出现Android Studio Gradle同步错误

卓学智
2023-03-14

我正在开发一个使用Android Studio的谷歌地图应用程序。当我将项目与Gradle文件同步(在Android Studio上选择Tools/Android/sync project with Gradle Files)时,我得到以下错误:

    null

我还在All Projects/Repositories部分中将maven url添加到Gradle项目文件中。

我尝试了堆栈溢出的建议,但没有一个不起作用。

有什么想法吗?

Gradle Project Build file:

// 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.0.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应用程序构建文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "hansen.scott.googlemaps"
        minSdkVersion 25
        targetSdkVersion 26
        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:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.google.android.gms:play-services-maps:11.6.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

错误在行中:implementation'com.google.android.gms:play-services-maps:11.6.2'

共有1个答案

长孙正卿
2023-03-14

请尝试在项目级分级文件中添加此内容

allprojects {
    repositories {
        maven {
            url "https://maven.google.com"
        }
    }
}
 类似资料: