Monday, 15 March 2010

Android Google Map API V2 Blank Screen -



Android Google Map API V2 Blank Screen -

hi followed vogella's tutorial on google map api v2. code similar his. reason map shows blank , logcat shows no error either. followed video sha1 finger print set api key within manifest file. used debug keystore c:\users\username.android\debug.keystore default debug keystore located in eclipse -> windows -> preference -> android -> build.

i generated new api key , still doesn't work.

manifest file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.barcodelibrary" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="11" android:targetsdkversion="15" /> <permission android:name="com.example.mapdemo.permission.maps_receive" android:protectionlevel="signature" /> <uses-feature android:glesversion="0x00020000" android:required="true" /> <uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera.autofocus" /> <uses-feature android:name="android.hardware.camera.flash" /> <uses-permission android:name="android.permission.internet"/> <uses-permission android:name="android.permission.camera"/> <uses-permission android:name="android.permission.internet"/> <uses-permission android:name="android.permission.vibrate"/> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.set_debug_app"></uses-permission> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name=".homeactivity" android:label="@string/title_activity_home" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name=".scanactivity"/> <activity android:name=".mapactivity"/> <activity android:name=".barcodehelper"/> <activity android:name=".jsonhelper"/> <meta-data android:name="com.google.android.maps.v2.api_key" android:value="my api key" /> </application> </manifest>

this layout file map activity:

<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=".mapactivity" > <fragment android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.mapfragment" /> </relativelayout>

this map activity:

public class mapactivity 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_map); 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))); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.activity_map, menu); homecoming true; } }

thanks!

you have couple of permission issues manifest. first, in next need replace bundle name package, need uses-permission

<permission android:name="com.example.mapdemo.permission.maps_receive" android:protectionlevel="signature" />

per bundle name, should --

<permission android:name="com.example.barcodelibrary.permission.maps_receive" android:protectionlevel="signature"/> <uses-permission android:name="com.example.barcodelibrary.permission.maps_receive"/>

finally, seem missing next permissions specifying permissions section of getting started guide --

<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"/>

android google-maps google-maps-android-api-2

No comments:

Post a Comment