为什么我收到错误:包com.google.android.maps不存在?

时间:2016-06-16 23:57:58

标签: java android android-studio gradle

我正在制作Android应用,但我一直收到此错误...

/code bases/2016/app/src/main/java/com/app/apps/android/appt/object/Route.java:3: error: package com.google.android.maps does not exist import com.google.android.maps.GeoPoint;

Android工作室在地图部分是红色的......

import com.google.android.maps.GeoPoint;

这是我完整的Gradle文件...

buildscript {
    repositories {
        jcenter();
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {

        classpath 'com.google.gms:google-services:1.3.0-beta1'
        classpath 'com.android.tools.build:gradle:1.5.0'
        // The Fabric Gradle plugin uses an open ended version to react
        // quickly to Android tooling updates
        classpath 'io.fabric.tools:gradle:1.21.5'

        //classpath 'io.fabric.tools:gradle:2.1.2'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {

    useLibrary 'org.apache.http.legacy'

    compileSdkVersion 23
    buildToolsVersion '24.0.0'

    dexOptions {
        //maxProcessCount 2
        incremental true
        javaMaxHeapSize "2g"
    }

    signingConfigs {
        config {
            keyAlias 'myApp'
            keyPassword '2012'
            storeFile file('/myApp')
            storePassword '2012'
        }
    }

    defaultConfig {
        applicationId "com.myApp.apps.android.maint"
        minSdkVersion 23
        targetSdkVersion 23
        versionCode 21
        versionName '3.51'
        signingConfig signingConfigs.config
    }

    buildTypes {
        debug {
            debuggable true
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        release {
            debuggable false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
        }
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/DEPENDENCIES'
    }

    productFlavors {
        //releaseDev {}
        //releaseIOSTest {}
        releaseTest {}
        releaseLive {}
    }
}

repositories {
    jcenter();
    maven { url "https://jitpack.io" }
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
        transitive = true;
    }
    compile 'com.google.android.gms:play-services-gcm:9.0.2'
    compile 'com.google.android.gms:play-services-location:9.0.2'
    compile 'com.google.android.gms:play-services-maps:9.0.2'
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.android.support:support-v4:24.0.0'
    compile 'com.android.support:cardview-v7:24.0.0'
    compile 'com.android.support:recyclerview-v7:24.0.0'
    compile 'com.google.code.gson:gson:2.4'
    compile 'joda-time:joda-time:2.9.2'
    compile 'com.github.PhilJay:MPAndroidChart:v2.1.0'
    compile 'com.google.maps:google-maps-services:0.1.15'
    compile 'com.google.android:android:4.1.1.4'
}

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

1 个答案:

答案 0 :(得分:3)

您应升级Google存储库库,并更改以下代码:

classpath 'com.google.gms:google-services:1.3.0-beta1'

classpath 'com.google.gms:google-services:3.0.0'

compile 'com.google.maps:google-maps-services:0.1.15'

compile 'com.google.android.gms:play-services-maps:9.0.2'

在此处阅读更多https://developers.google.com/android/guides/setup