In my android app supporting 2.2 and higher, I am trying to use the google maps api v2.
I have this so far:
Does anyone know what the issue is?
Thanks.
xml
<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" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".Activity_Map" > <fragment android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.SupportMapFragment"/> </RelativeLayout>
java
import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.SupportMapFragment; import android.location.Geocoder; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.view.Menu; public class Activity_Map extends FragmentActivity { GoogleMap map = null; Geocoder coder; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_map); map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap(); coder = new Geocoder(this); } @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; } }
Manifest
<permission android:name="sord.common.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="sord.common.permission.MAPS_RECEIVE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.CALL_PHONE" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="sord.ids_connect.Activity_Login" android:label="@string/app_name" android:screenOrientation="portrait" android:windowSoftInputMode="adjustResize|stateHidden" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="sord.ids_connect.Activity_Menu" android:label="@string/title_activity_menu" android:screenOrientation="portrait" android:theme="@style/Theme.AppCompat.Light.DarkActionBar" > </activity> <activity android:name="sord.ids_connect.Activity_Profile" android:label="@string/title_activity_profile" android:screenOrientation="portrait" android:theme="@style/Theme.AppCompat.Light.DarkActionBar" > </activity> <activity android:name="sord.ids_connect.Activity_Map" android:screenOrientation="portrait" android:label="@string/title_activity_map" android:theme="@android:style/Theme.NoTitleBar" > </activity> <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="MY-KEY" /> </application>
CRASH LOG
12-29 22:44:58.103: E/AndroidRuntime(7331): FATAL EXCEPTION: main 12-29 22:44:58.103: E/AndroidRuntime(7331): java.lang.RuntimeException: Unable to start activity ComponentInfo{sord.ids_connect/sord.ids_connect.Activity_Map}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment 12-29 22:44:58.103: E/AndroidRuntime(7331): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110) 12-29 22:44:58.103: E/AndroidRuntime(7331): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135) 12-29 22:44:58.103: E/AndroidRuntime(7331): at android.app.ActivityThread.access$700(ActivityThread.java:143) 12-29 22:44:58.103: E/AndroidRuntime(7331): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241) 12-29 22:44:58.103: E/AndroidRuntime(7331): at android.os.Handler.dispatchMessage(Handler.java:99) 12-29 22:44:58.103: E/AndroidRuntime(7331): at android.os.Looper.loop(Looper.java:137) 12-29 22:44:58.103: E/AndroidRuntime(7331): at android.app.ActivityThread.main(ActivityThread.java:4950) 12-29 22:44:58.103: E/AndroidRuntime(7331): at java.lang.reflect.Method.invokeNative(Native Method) 12-29 22:44:58.103: E/AndroidRuntime(7331): at java.lang.reflect.Method.invoke(Method.java:511) 12-29 22:44:58.103: E/AndroidRuntime(7331): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004) 12-29 22:44:58.103: E/AndroidRuntime(7331): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771) 12-29 22:44:58.103: E/AndroidRuntime(7331): at dalvik.system.NativeStart.main(Native Method) 12-29 22:44:58.103: E/AndroidRuntime(7331): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment 12-29 22:44:58.103: E/AndroidRuntime(7331): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 12-29 22:44:58.103: E/AndroidRuntime(7331): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 12-29 22:44:58.103: E/AndroidRuntime(7331): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 12-29 22:44:58.103: E/AndroidRuntime(7331): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 12-29 22:44:58.103: E/AndroidRuntime(7331): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 12-29 22:44:58.103: E/AndroidRuntime(7331): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:316) 12-29 22:44:58.103: E/AndroidRuntime(7331): at android.app.Activity.setContentView(Activity.java:1915) 12-29 22:44:58.103: E/AndroidRuntime(7331): at sord.ids_connect.Activity_Map.onCreate(Activity_Map.java:18) 12-29 22:44:58.103: E/AndroidRuntime(7331): at android.app.Activity.performCreate(Activity.java:5177) 12-29 22:44:58.103: E/AndroidRuntime(7331): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094) 12-29 22:44:58.103: E/AndroidRuntime(7331): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074) 12-29 22:44:58.103: E/AndroidRuntime(7331): ... 11 more 12-29 22:44:58.103: E/AndroidRuntime(7331): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4030500 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> 12-29 22:44:58.103: E/AndroidRuntime(7331): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source) 12-29 22:44:58.103: E/AndroidRuntime(7331): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source) 12-29 22:44:58.103: E/AndroidRuntime(7331): at com.google.android.gms.maps.internal.q.v(Unknown Source) 12-29 22:44:58.103: E/AndroidRuntime(7331): at com.google.android.gms.maps.internal.q.u(Unknown Source) 12-29 22:44:58.103: E/AndroidRuntime(7331): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source) 12-29 22:44:58.103: E/AndroidRuntime(7331): at com.google.android.gms.maps.SupportMapFragment$b.cE(Unknown Source) 12-29 22:44:58.103: E/AndroidRuntime(7331): at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source) 12-29 22:44:58.103: E/AndroidRuntime(7331): at com.google.android.gms.dynamic.a.a(Unknown Source) 12-29 22:44:58.103: E/AndroidRuntime(7331): at com.google.android.gms.dynamic.a.onInflate(Unknown Source) 12-29 22:44:58.103: E/AndroidRuntime(7331): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source) 12-29 22:44:58.103: E/AndroidRuntime(7331): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:290) 12-29 22:44:58.103: E/AndroidRuntime(7331): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676) 12-29 22:44:58.103: E/AndroidRuntime(7331): ... 21 more