java - error with google map v2 -
i trying display or see google maps on app.
- i have added library google_play_services_lib(no error).
- obtain google maps api key.
- follow code in http://www.vogella.com/tutorials/androidgooglemaps/article.html#overview_intro (no error).
- but run app in emulator, stopped. says "unfortunately showmapactivity has stopped ".
i not getting error. think problem in xml file.fragment not working. should now. plz me or give me simple sample project using google map. beginner @ google map in android , trying badly fix but......:(
here activity_main.xml file :
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".mainactivity" > <fragment android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.mapfragment" /> </relativelayout>
mainactivity.java file :
package com.vogella.android.locationapi.maps; import android.app.activity; import android.os.bundle; import android.view.menu; import com.google.android.gms.maps.cameraupdatefactory; import com.google.android.gms.maps.googlemap; import com.google.android.gms.maps.mapfragment; import com.google.android.gms.maps.model.bitmapdescriptorfactory; import com.google.android.gms.maps.model.latlng; import com.google.android.gms.maps.model.marker; import com.google.android.gms.maps.model.markeroptions; public class mainactivity extends activity { static final latlng hamburg = new latlng(53.558, 9.927); static final latlng kiel = new latlng(53.551, 9.993); private googlemap map; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); /*map = ((mapfragment) getfragmentmanager().findfragmentbyid(r.id.map)) .getmap(); marker hamburg = map.addmarker(new markeroptions().position(hamburg) .title("hamburg")); marker kiel = map.addmarker(new markeroptions() .position(kiel) .title("kiel") .snippet("kiel cool") .icon(bitmapdescriptorfactory .fromresource(r.drawable.ic_launcher))); // move camera instantly hamburg zoom of 15. map.movecamera(cameraupdatefactory.newlatlngzoom(hamburg, 15)); // zoom in, animating camera. map.animatecamera(cameraupdatefactory.zoomto(10), 2000, null); */ } @override public boolean oncreateoptionsmenu(menu menu) { getmenuinflater().inflate(r.menu.main, menu); return true; } }
and androidmanifest.xml file:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.vogella.android.locationapi.maps" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="11" android:targetsdkversion="19" /> <permission android:name="com.vogella.android.locationapi.maps.permission.maps_receive" android:protectionlevel="signature" /> <uses-feature android:glesversion="0x00020000" android:required="true" /> <uses-permission android:name="com.vogella.android.locationapi.maps.permission.maps_receive" /> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.write_external_storage" /> <uses-permission android:name="com.google.android.providers.gsf.permission.read_gservices" /> <uses-permission android:name="android.permission.access_coarse_location" /> <uses-permission android:name="android.permission.access_fine_location" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name="com.vogella.android.locationapi.maps.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.maps.v2.aizasyadyrvyrg68lvuq0721d_iaw0vlaemjnua" android:value="aizasyadyrvyrg68lvuq0721d_iaw0vlaemjnua" /> </application> </manifest>
replace meta-data
in androidmanifest.xml
file one.
<meta-data android:name="com.google.android.maps.v2.api_key" android:value="aizasyadyrvyrg68lvuq0721d_iaw0vlaemjnua" />
also add meta-data
too.
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
hope solve problems.
Comments
Post a Comment