Hi I recently followed Vogella's tutorial on Google Map API v2. The code is similar to his. But for some reason the map shows up blank and the logcat shows no error either. I also followed this video to get the SHA1 finger print then I put the API key inside the manifest file. I used the debug keystore C:\Users\UserName.android\debug.keystore which is also the default debug keystore located in Eclipse -> Windows -> Preference -> Android -> Build.
I also generated a new API key and it 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 is my layout file for the 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 is my 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 is cool") .icon(BitmapDescriptorFactory .fromResource(R.drawable.ic_launcher))); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.activity_map, menu); return true; } }
Thanks!
This problem generally happens when you have too many bugged cookies in your browser or cached data in your Android app. The best solution to blank Google Maps is getting rid of the unwanted data from your mobile app or web browser.
There are a several reasons why your google maps may not be working, the most common issue being no Google Map API key set or set incorrectly. To use the Google Maps JavaScript API, you must register your app project on the Google Cloud Platform Console and get a Google API key which you can add to your app.
You have couple of permission issues with your manifest. First, in the following you need to replace the package name with your package, you also need to as a uses-permission
<permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" android:protectionLevel="signature" />
per your package name, should be --
<permission android:name="com.example.barcodelibrary.permission.MAPS_RECEIVE" android:protectionLevel="signature"/> <uses-permission android:name="com.example.barcodelibrary.permission.MAPS_RECEIVE"/>
Finally, you seem to be missing the following permissions from the specifying permissions section of the 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"/>
For me it turned out that I didn't enabled the Google Maps Android API v2
. We were using another Google Maps API which I assumed to be the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With