Importing Google maps sample project and Google play services lib to Android studio

时间:2015-06-25 18:13:44

标签: android google-maps

I'm working with Android Studio 1.2.2 and I don't know how to solve this problem:

error: package com.google.android.maps does not exist.

I added these lines to may build.gradle file under dependencies:

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

But the same error is appearing when I try to build the project.

enter image description here

2 个答案:

答案 0 :(得分:1)

你的包名似乎不正确,应该是:

import com.google.android.gms.maps.*;

您需要点击here链接或视频here来设置地图。

确保您编译最新的播放服务:

compile 'com.google.android.gms:play-services:7.5.0'

并在permission, feature, mata-data(apikey and gems version)中加入AndroidManifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.bojie.map_basic_android" >

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <!--
         The following two permissions are not required to use
         Google Maps Android API v2, but are recommended.
    -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />


    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="YOUR API KEY" />
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
    </application>

</manifest>

对于演示项目,您可以参考here

答案 1 :(得分:0)

Please ensure that you have downloaded and installed the Google Play services SDK in your Android SDK Manager Also you can try declaring this in your Manifest.xml <uses-library android:name="com.google.android.maps" />