I'm trying to create and application that connects with Google maps. But when the screen loads where the map should be its just grey. How do I fix this?
The important message from my logcat.
06-11 03:32:55.196: E/Google Maps Android API(11671):
Ensure that the following correspond to what is in the API Console: Package Name: my pacakage,
API Key: my key,
Certificate Fingerprint: my fingerprint
The Activity
import android.os.Bundle;
import android.view.Menu;
import android.support.v4.app.FragmentActivity;
public class mapPage extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_page);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="my package"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="my package.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="my package.permission.MAPS_RECEIVE"/>
<!-- Copied from Google Maps Library/AndroidManifest.xml. -->
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- External storage for caching. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- My Location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!-- Maps API needs OpenGL ES 2.0. -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<!-- End of copy. -->
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my key"/>
<activity
android:name="my package.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=".main">
</activity>
<activity android:name=".mapPage">
</activity>
<activity android:name=".ThirdPartyWeb"
android:theme="@android:style/Theme.Dialog">
</activity>
</application>
</manifest>
The layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:layout_height="250dp"
android:layout_width="fill_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
<ImageView
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:layout_height="50dp"
android:layout_width="fill_parent"
android:background="@color/darkGrey"/>
<Button
android:layout_alignParentTop="true"
android:layout_marginTop="10dp"
android:layout_alignParentLeft="true"
android:id="@+id/menuButton"
android:background="@drawable/icon_menu"
android:layout_height="30dp"
android:layout_width="30dp"/>
<Button
android:layout_alignParentTop="true"
android:layout_marginTop="10dp"
android:layout_toRightOf="@+id/menuButton"
android:layout_marginLeft="20dp"
android:id="@+id/"
android:background="@drawable/icon_off"
android:layout_height="35dp"
android:layout_width="55dp"/>
<EditText
android:layout_alignParentTop="true"
android:layout_width="wrap_content"
android:layout_marginTop="10dp"
android:layout_toRightOf="@+id/"
android:layout_marginLeft="20dp"
android:layout_toEndOf="@+id/"
android:id="@+id/seachBox"
android:hint="@string/search"
android:layout_height="35dp"
android:layout_alignParentEnd="true"
android:background="@color/white"/>
<Button
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_marginTop="10dp"
android:id="@+id/searchButton"
android:background="@drawable/graphic_search"
android:layout_height="35dp"
android:layout_width="20dp"/>
<ImageView
android:layout_above="@+id/newsFeed"
android:layout_centerInParent="true"
android:layout_height="35dp"
android:layout_width="fill_parent"
android:background="@color/darkGrey"/>
<TextView
android:layout_alignParentLeft="true"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_above="@+id/newsFeed"
android:layout_marginBottom="11dp"
android:textColor="@color/white"
android:text="@string/news_feed"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<ListView
android:layout_alignParentBottom="true"
android:id="@+id/newsFeed"
android:layout_width="fill_parent"
android:layout_height="wrap_content">"
</ListView>
</RelativeLayout>
Ok problem solved. On the google api console, there is two google map api v2's. I had the one just for google maps api v2 if you look just above it, it says google maps v2 android. I turned on that one as well and the map is running.
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