我的地图不会出现。我甚至不会在Log Cat中获得地图网格或任何错误消息。我没有得到任何类型的“无法通过谷歌API验证”或类似的东西(这让我相信我的api密钥是正确的)。我根本没有得到任何类型的地图。
配置&清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.proximitystuff"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="17" />
<permission
android:name="com.example.mapdemo.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.proximitystuff.permission.MAPS_RECEIVE"/>
<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"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- 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="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<uses-library
android:name="com.google.android.maps"/>
<activity
android:name="com.example.proximitystuff.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>
<activity
android:name="com.example.proximitystuff.MyMapActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAPACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<service
android:name="com.example.proximitystuff.ProxyBackgroundCheck"
android:enabled="true"
android:permission="com.example.ADAMS_PROX_PERMISSION" >
</service>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyBnQNgn166qfatch_xcFwL8K0AfVHBYcGA"/>
</application>
</manifest>
Java代码和XML布局: 我的主要活动使用按钮进入屏幕截图中显示的地图活动。此地图活动的代码是基于最基本的功能,但仍然无法正常工作。我得到的一个理论是,由于这个类不继承“FragmentActivity”,因此它可以使用xml片段(如果是这种情况,我希望在日志中至少会出现某种类型的错误)。 / p>
package com.example.proximitystuff;
import android.app.Activity;
import android.os.Bundle;
public class MyMapActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_map);
}
}
My XML layout is using the most basic layout possible.
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
Project.properties
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-17
android.library.reference.1=../google-play-services_lib
Proguard(以防这是错误的):
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}
答案 0 :(得分:2)
我正在使用android模拟器
AFAIk,Android模拟器不支持Maps V2或任何涉及Play服务的内容。虽然他们已经宣布了一项解决方案,但我并未发现更新的图像已经发布。
答案 1 :(得分:1)
使用Android手机测试应用程序而不是使用模拟器,并尝试按照教程..真的很有用..
http://www.vogella.com/articles/AndroidGoogleMaps/article.html
答案 2 :(得分:1)
发现问题。显然我是个白痴,并且:
2个api密钥注册到相同的SHA1和相同的软件包名称...基本上我已经注册了两次API访问的应用程序(在API控制台上)并随意为我的清单选择了其中一个API密钥(Big“no no no “显然)。
因此,每个地图看起来只有一个API密钥,否则您将拥有一个没有任何日志错误的无法运行的应用。你也看不到任何瓷砖(空或不)。感谢您的帮助,希望这可以节省一些我经历过的试验和错误的时间。