首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >谷歌地图v2应用发布,但没有加载地图

谷歌地图v2应用发布,但没有加载地图
EN

Stack Overflow用户
提问于 2014-09-12 23:38:16
回答 1查看 56关注 0票数 0

我正在开发一个简单的Google v2应用程序。我遵循了androidhive.info的一些教程,等等。这些教程对他们非常有用,但对我却不适用。

androidmanifest.xml

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="artsofdevelopements.org.admaps" >

<permission
    android:name="artsofdevelopements.org.admaps.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<uses-permission android:name="artsofdevelopements.org.admaps.permission.MAPS_RECEIVE" />

<uses-sdk
    android:minSdkVersion="17"
    android:targetSdkVersion="20" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<!-- Required to show current location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<!-- Required OpenGL ES 2.0. for Maps V2 -->
<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />

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

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <!-- Goolge API Key -->
    <meta-data
            android:name="artsofdevelopements.org.admaps.AIzaSyD66Am2aXhahzwPMKqLV94O7HLIXnG8EPI"
        android:value="AIzaSyD66Am2aXhahzwPMKqLV94O7HLIXnG8EPI" />
</application>

build.gradle

代码语言:javascript
运行
复制
apply plugin: 'com.android.application'

android {
compileSdkVersion 17
buildToolsVersion "20.0.0"

defaultConfig {
    applicationId "ArtsOfDevelopements.org.ADMaps"
    minSdkVersion 17
    targetSdkVersion 20
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        runProguard true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['google-play-services.jar'])
compile 'com.google.android.gms:play-services:5.0.89'
compile 'com.android.support:appcompat-v7:20.0.0'
}

mapsactivity.java

代码语言:javascript
运行
复制
package artsofdevelopements.org.admaps;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;

class Maps extends FragmentActivity {
GoogleMap map;
double lat;
double lan;
boolean flag = false;

// private LocationManager lm;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);

    map = ((SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map)).getMap();
}
}

activity_maps.xml

代码语言:javascript
运行
复制
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent" >

    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="wrap_content"
        android:layout_height="match_parent" />

</RelativeLayout>

这个应用程序通常是在我的设备上编译和启动的,但我看到的只是缩放按钮和谷歌标志。无地图

请帮我解决这个问题

EN

回答 1

Stack Overflow用户

发布于 2014-09-12 23:44:16

我在您的清单中也看到了这个问题,但请将元数据中的名称更改为以下内容,并使用您自己的API密钥。

代码语言:javascript
运行
复制
<meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="@string/maps_v2_API_KEY" />

<meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25818403

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档