首页 > 解决方案 > Unable to resolve dependency for ':app@debug/compileClasspath': Cannot convert URL 'com.google.android.gms:play-services-maps:17.0.0' to a file

问题描述

I'm building the Google Maps demo from Android Coding on youtube. I built the app, but for some reason I keep getting the error message

Cannot convert URL 'com.google.android.gms:play-services-maps:17.0.0' to a file.

Here is my build.gradle(Project Google Maps Demo):

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

    buildscript {
        repositories {
            google()
            jcenter()
            mavenLocal()

        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.5.0'
            classpath 'com.google.gms:google-services:4.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.fabric.io/public' }
            maven {
                url "https://maven.google.com"
            }
        }
    }

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

Can anyone help? EDIT: Copied and pasted the same code twice, here is my actual build.gradle(module: app)**

Here is my app/build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.zydavia.googlemapsdemo"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation files('com.google.android.gms:play-services-maps:17.0.0')
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation 'com.google.android.gms:play-services:12.0.1'
    implementation 'androidx.navigation:navigation-fragment:2.1.0'
    implementation 'androidx.navigation:navigation-runtime:2.1.0'
    implementation 'androidx.navigation:navigation-ui-ktx:2.1.0'
}

标签: androidgoogle-maps-api-3android-gradle-plugingoogle-play-services

解决方案


删除这一行:

//implementation files('com.google.android.gms:play-services-maps:17.0.0')

推荐阅读