应用网格显示屏幕,而不是谷歌地图 [英] App shows grid screen instead of google map
问题描述
我想获得一个基本的地图应用程序工作,但,我只得到电网屏幕。
I am trying to get a basic map application to work but, I am getting only the grid screen.
code:
1.ActivityMain.java
1.ActivityMain.java
import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
public class MainActivity extends MapActivity {
MapView mapView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mapView = (MapView) findViewById(R.id.map_view);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
2.activity_main.xml
2.activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:enabled="true"
android:apiKey="[api_key]" />
</RelativeLayout>
3.Manifest.xml
3.Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vevolet.maps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<permission
android:name="com.vevolet.maps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" >
</permission>
<uses-permission android:name="com.vevolet.maps.permission.MAPS_RECEIVE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<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:required="true" android:name="com.google.android.maps" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="[api_key]" />
<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>
</application>
</manifest>
我也试过这code API与使用从没有工作的application..but产生的密钥库生成的。
I also tried this code with api generated using the keystore generated from the application..but it did not work.
请告诉我是什么问题。谢谢
Please tell me what the problem is. Thanks
推荐答案
我觉得pretty愚蠢的回答我的问题(特别是与它的奖金),但我无论如何做。
I feel pretty stupid answering my own question(esp. with a bounty on it) but I'm doing it anyway.
Raghunandan
和周华健ADZ
解决的第一个错误,我做了(混合GMaps实现v1和v2 code的), 感谢你们。
等后来我遇到了两个问题:
Raghunandan
and Emil Adz
solved the first mistake I did(of mixing gmaps v1 and v2 code), thank you guys.
But then I encountered two other problems:
问题1:库是失败与我的项目链接结果
问题2:我得到了一个错误错误充气类片段
Problem 1: The library was failing to link with my project.
Problem 2: I was getting an error "error inflating the class fragment"
解决方案:
有关问题1:我复制内部C的
,并将其粘贴到另一个驱动器,然后输入它的新位置,并将其引用到我的项目。的Google Play-services_lib
文件夹:\\ Android的\\ android- SDK \\ \\演员谷歌\\ google_play_services \\ libproject
For Problem 1: I copied the google-play-services_lib
folder inside C:\Android\android-sdk\extras\google\google_play_services\libproject
and pasted it into another drive and then imported it from the new location and referenced it to my project.
有关问题2:我更换了 MapFragment
与 SupportMapFragment
里面&LT;片断&gt;
这是片段的原生API等级11版(我的活动XML中)
For Problem 2: I replaced the MapFragment
with SupportMapFragment
in inside <fragment>
(inside my activity xml) which is for the native API Level 11 edition of fragments.
这篇关于应用网格显示屏幕,而不是谷歌地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!