Unfortunately google maps has stopped - android

I would get google map on my emulator.
I followed the instructions on
When I run the application an error's message appears:Unfortunately DemoGoogleMapsV2 has stopped.
my androidmanifest.xml:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission android:name="com.demogooglemapsv2.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.demogooglemapsv2.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- The following two permissions are not required to use
Google Maps Android API, but are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<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="API_KEY"/>
<activity
android:name=".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>
</application>
</manifest>
my activity_main.xml:
<android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
my MainActivity.java:
package com.demogooglemapsv2;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
the log error:
09-04 17:43:51.170: E/Trace(1477): error opening trace file: No such
file or directory (2) 09-04 17:43:53.449: E/AndroidRuntime(1477):
FATAL EXCEPTION: main 09-04 17:43:53.449: E/AndroidRuntime(1477):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.demogooglemapsv2/com.demogooglemapsv2.MainActivity}:
android.view.InflateException: Binary XML file line #11: Error
inflating class fragment 09-04 17:43:53.449: E/AndroidRuntime(1477):
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
09-04 17:43:53.449: E/AndroidRuntime(1477): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
09-04 17:43:53.449: E/AndroidRuntime(1477): at
android.app.ActivityThread.access$600(ActivityThread.java:141) 09-04
17:43:53.449: E/AndroidRuntime(1477): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
09-04 17:43:53.449: E/AndroidRuntime(1477): at
android.os.Handler.dispatchMessage(Handler.java:99) 09-04
17:43:53.449: E/AndroidRuntime(1477): at
android.os.Looper.loop(Looper.java:137) 09-04 17:43:53.449:
E/AndroidRuntime(1477): at
android.app.ActivityThread.main(ActivityThread.java:5041) 09-04
17:43:53.449: E/AndroidRuntime(1477): at
java.lang.reflect.Method.invokeNative(Native Method) 09-04
17:43:53.449: E/AndroidRuntime(1477): at
java.lang.reflect.Method.invoke(Method.java:511) 09-04 17:43:53.449:
E/AndroidRuntime(1477): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
09-04 17:43:53.449: E/AndroidRuntime(1477): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 09-04
17:43:53.449: E/AndroidRuntime(1477): at
dalvik.system.NativeStart.main(Native Method) 09-04 17:43:53.449:
E/AndroidRuntime(1477): Caused by: android.view.InflateException:
Binary XML file line #11: Error inflating class fragment 09-04
17:43:53.449: E/AndroidRuntime(1477): at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
09-04 17:43:53.449: E/AndroidRuntime(1477): at
android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 09-04
17:43:53.449: E/AndroidRuntime(1477): at
android.view.LayoutInflater.inflate(LayoutInflater.java:489) 09-04
17:43:53.449: E/AndroidRuntime(1477): at
android.view.LayoutInflater.inflate(LayoutInflater.java:396) 09-04
17:43:53.449: E/AndroidRuntime(1477): at
android.view.LayoutInflater.inflate(LayoutInflater.java:352) 09-04
17:43:53.449: E/AndroidRuntime(1477): at
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
09-04 17:43:53.449: E/AndroidRuntime(1477): at
android.app.Activity.setContentView(Activity.java:1881) 09-04
17:43:53.449: E/AndroidRuntime(1477): at
com.demogooglemapsv2.MainActivity.onCreate(MainActivity.java:17) 09-04
17:43:53.449: E/AndroidRuntime(1477): at
android.app.Activity.performCreate(Activity.java:5104) 09-04
17:43:53.449: E/AndroidRuntime(1477): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
09-04 17:43:53.449: E/AndroidRuntime(1477): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
09-04 17:43:53.449: E/AndroidRuntime(1477): ... 11 more 09-04
17:43:53.449: E/AndroidRuntime(1477): Caused by:
java.lang.IllegalStateException: The meta-data tag in your app's
AndroidManifest.xml does not have the right value. Expected 5089000
but found 0. You must have the following declaration within the
element: 09-04
17:43:53.449: E/AndroidRuntime(1477): at
com.google.android.gms.common.GooglePlayServicesUtil.A(Unknown Source)
09-04 17:43:53.449: E/AndroidRuntime(1477): at
com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown
Source) 09-04 17:43:53.449: E/AndroidRuntime(1477): at
com.google.android.gms.maps.internal.u.I(Unknown Source) 09-04
17:43:53.449: E/AndroidRuntime(1477): at
com.google.android.gms.maps.internal.u.H(Unknown Source) 09-04
17:43:53.449: E/AndroidRuntime(1477): at
com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
09-04 17:43:53.449: E/AndroidRuntime(1477): at
com.google.android.gms.maps.SupportMapFragment$b.jz(Unknown Source)
09-04 17:43:53.449: E/AndroidRuntime(1477): at
com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
09-04 17:43:53.449: E/AndroidRuntime(1477): at
com.google.android.gms.dynamic.a.a(Unknown Source) 09-04 17:43:53.449:
E/AndroidRuntime(1477): at
com.google.android.gms.dynamic.a.onInflate(Unknown Source) 09-04
17:43:53.449: E/AndroidRuntime(1477): at
com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown
Source) 09-04 17:43:53.449: E/AndroidRuntime(1477): at
android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:291)
09-04 17:43:53.449: E/AndroidRuntime(1477): at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
09-04 17:43:53.449: E/AndroidRuntime(1477): ... 21 more

Replace FragmentActivity in place of Activity, make sure you are entering right api key.
And in place of
com.google.android.gms.maps.MapFragment
use
com.google.android.gms.maps.SupportMapFragment
Make sure google play services is installed on your device. That's why try to run the application on real device not on the emulator.

Add the following activity_main.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"
/>
</LinearLayout>

add this tag in your menifest file
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />

Hope your project and google-play-services_lib both are in same workspace and you have added it as library project in your application. If your API-Key is ok then you need to change like this.
1. add this meta-data inside application tag in manifest
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
2. As minSdkVersion="8" you should use SupportMapFragment so activity_main.xml looks like this
<?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
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
3. Instead of Activity you should extend FragmentActivity and use SupportFragmentManager()
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
GoogleMap mMap = fm.getMap();
}
}
Try to run it on real device or Genymotion's emulator after installing
google-play-service. Otherwise you will face a crash

Related

android.view.InflateException: Binary XML file line #3: Error inflating class fragment [duplicate]

This question already has answers here:
After Google Play Service update to version 13 I got an error
(8 answers)
GoogleAPI key V2 RuntimeException [closed]
(1 answer)
Closed 8 years ago.
Im Creating an app step by step using this tutorial : google map api v2
But I'm getting Error ! I already tried and read many answer to resolve the error! But I can't resolve it
Logcat :
12-10 10:30:02.975: E/AndroidRuntime(2249): FATAL EXCEPTION: main
12-10 10:30:02.975: E/AndroidRuntime(2249): Process: com.example.finalymapapi, PID: 2249
12-10 10:30:02.975: E/AndroidRuntime(2249): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.finalymapapi/com.example.finalymapapi.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.app.ActivityThread.access$800(ActivityThread.java:135)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.os.Handler.dispatchMessage(Handler.java:102)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.os.Looper.loop(Looper.java:136)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.app.ActivityThread.main(ActivityThread.java:5017)
12-10 10:30:02.975: E/AndroidRuntime(2249): at java.lang.reflect.Method.invokeNative(Native Method)
12-10 10:30:02.975: E/AndroidRuntime(2249): at java.lang.reflect.Method.invoke(Method.java:515)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
12-10 10:30:02.975: E/AndroidRuntime(2249): at dalvik.system.NativeStart.main(Native Method)
12-10 10:30:02.975: E/AndroidRuntime(2249): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.app.Activity.setContentView(Activity.java:1929)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.example.finalymapapi.MainActivity.onCreate(MainActivity.java:14)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.app.Activity.performCreate(Activity.java:5231)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
12-10 10:30:02.975: E/AndroidRuntime(2249): ... 11 more
12-10 10:30:02.975: E/AndroidRuntime(2249): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4452000 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-10 10:30:02.975: E/AndroidRuntime(2249): at com.google.android.gms.common.GooglePlayServicesUtil.t(Unknown Source)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.google.android.gms.maps.internal.u.B(Unknown Source)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.google.android.gms.maps.internal.u.A(Unknown Source)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.google.android.gms.maps.SupportMapFragment$b.ip(Unknown Source)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.google.android.gms.dynamic.a.a(Unknown Source)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:290)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
12-10 10:30:02.975: E/AndroidRuntime(2249): ... 20 more
Im get SHA1 from eclipse->Window->Preferences->android->Build
and my Manifist file :
<permission
android:name="your_package_name.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="your_package_name.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"/>
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.finalymapapi.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.API_KEY"
android:value="AIzaSyAHkTtRSWMcC-mUz9jH9CBlrxoeV2Qon7c"/>
</application>
</manifest>
and my activity file :
My javafile :
add <meta-data> tag in <application> tag in your manifest.xml
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
if still crashes then check:
Use the mapFragment element as below in the xml
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_below="#+id/lineartab" />
You need to check the project properties:
Does Google API's selected?
Google play service lib project added?
Hope this helps.
As mentioned in the exception add the following line to <application> in you AndroidManifest.xml
<meta-data android:name="com.google.android.gms.version"android:value="#integer/google_play_services_version" />

Google Map api v2 application stop working

I am trying to run Google maps API v2 on emulator. It says "unfortunately app has stoped" Here is my manifest.xml code. There is a huge number of errors. In the first line it gives error to define android.allowBackup which I have done on application tag.Please help me solve them.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permissionandroid:name="com.myapp.providers.gsf.permission.
READ_GSERVICES"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data android:name="com.google.android.gms.version" android:value="4030500" />
<!-- <meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" /> -->
<activity
android:name="com.myapp.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.API_KEY"
android:value="My key"/>
</application>
</manifest>
----------------------------------------------------------------------------------------------
MainActivity.java
package myapp;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
public class MainActivity extends FragmentActivity {
private GoogleMap map;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SupportMapFragment mapFrag = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
map = mapFrag.getMap();
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
}
}
------------------------------------------------------------------------------------
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment"/>
-----------------------------------------------------------------
Logcat
E/Trace(690): error opening trace file: No such file or directory (2)
E/AndroidRuntime(690): FATAL EXCEPTION: main
E/AndroidRuntime(690): java.lang.RuntimeException:
Unable to start activity
ComponentInfo{myapp/myapp.MainActivity}:android.view.InflateException: Binary XML file line #2:
Error inflating class fragment
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
android.app.ActivityThread.access$600(ActivityThread.java:130)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:137)
android.app.ActivityThread.main(ActivityThread.java:4745)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
dalvik.system.NativeStart.main(Native Method)
09-01 15:06:56.709: E/AndroidRuntime(690): Caused by: android.view.InflateException: Binary XML
file line #2: Error inflating class fragment
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
android.view.LayoutInflater.inflate(LayoutInflater.java:466)
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
android.view.LayoutInflater.inflate(LayoutInflater.java:352)
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
android.app.Activity.setContentView(Activity.java:1867)
android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.
java:110)
android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
myapp.MainActivity.onCreate(MainActivity.java:14)
android.app.Activity.performCreate(Activity.java:5008)
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
AndroidRuntime(690): ... 11 more
AndroidRuntime(690): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's
AndroidManifest.xml does not have the right value. Expected 5089000 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" />
com.google.android.gms.common.GooglePlayServicesUtil.A(Unknown Source)
com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable
(Unknown Source)
com.google.android.gms.maps.internal.u.I(Unknown Source)
com.google.android.gms.maps.internal.u.H(Unknown Source)
com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
com.google.android.gms.maps.MapFragment$b.jz(Unknown Source)
com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
com.google.android.gms.dynamic.a.a(Unknown Source)
com.google.android.gms.dynamic.a.onInflate(Unknown Source)
com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
android.app.Activity.onCreateView(Activity.java:4663)
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
09-01 15:06:56.709: E/AndroidRuntime(690): ... 23 more
09-01 15:07:53.868: E/Trace(734): error opening trace file: No such file or directory (2)
09-01 15:07:54.479: E/AndroidRuntime(734): FATAL EXCEPTION: main
09-01 15:07:54.479: E/AndroidRuntime(734): java.lang.RuntimeException:
Unable to start activity ComponentInfo{myapp/myapp.MainActivity}
android.view.InflateException: Binary XML file line #2: Error inflating class fragment
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
android.app.ActivityThread.access$600(ActivityThread.java:130)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:137)
android.app.ActivityThread.main(ActivityThread.java:4745)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
dalvik.system.NativeStart.main(Native Method)
09-01 15:07:54.479: E/AndroidRuntime(734): Caused by:
android.view.InflateException: Binary XML file line #2: Error inflating class fragment
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
android.view.LayoutInflater.inflate(LayoutInflater.java:466)
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
android.view.LayoutInflater.inflate(LayoutInflater.java:352)
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
android.app.Activity.setContentView(Activity.java:1867)
android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
android.support.v7.app.ActionBarActivityDelegateICS.
setContentView(ActionBarActivityDelegateICS.java:110)
android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
myapp.MainActivity.onCreate(MainActivity.java:14)
android.app.Activity.performCreate(Activity.java:5008)
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
E/AndroidRuntime(734): ... 11 more
E/AndroidRuntime(734): Caused by: java.lang.IllegalStateException: The meta-data tag in your
app's AndroidManifest.xml does not have the right value. Expected 5089000 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" />
com.google.android.gms.common.GooglePlayServicesUtil.A(Unknown Source)
com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable
(Unknown Source)
com.google.android.gms.maps.internal.u.I(Unknown Source)
com.google.android.gms.maps.internal.u.H(Unknown Source)
com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
com.google.android.gms.maps.MapFragment$b.jz(Unknown Source)
com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
com.google.android.gms.dynamic.a.a(Unknown Source)
com.google.android.gms.dynamic.a.onInflate(Unknown Source)
com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
android.app.Activity.onCreateView(Activity.java:4663)
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
09-01 15:07:54.479: E/AndroidRuntime(734): ... 23 more
error opening trace file: No such file or directory (2)
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{myapp/myapp.MainActivity}:
android.view.InflateException: Binary XML file line #2: Error inflating class fragment
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
android.app.ActivityThread.access$600(ActivityThread.java:130)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:137)
android.app.ActivityThread.main(ActivityThread.java:4745)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
dalvik.system.NativeStart.main(Native Method)
09-01 15:12:22.938: E/AndroidRuntime(811): Caused by: android.view.InflateException: Binary XML
file line #2: Error inflating class fragment
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
android.view.LayoutInflater.inflate(LayoutInflater.java:466)
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
android.view.LayoutInflater.inflate(LayoutInflater.java:352)
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
android.app.Activity.setContentView(Activity.java:1867)
android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
android.support.v7.app.ActionBarActivityDelegateICS.setContentView
(ActionBarActivityDelegateICS.java:110)
android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
myapp.MainActivity.onCreate(MainActivity.java:14)
android.app.Activity.performCreate(Activity.java:5008)
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
09-01 15:12:22.938: E/AndroidRuntime(811): ... 11 more
09-01 15:12:22.938: E/AndroidRuntime(811): Caused by: java.lang.IllegalStateException: The meta-
data tag in your app's AndroidManifest.xml does not have the right value. Expected 5089000
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" />
com.google.android.gms.common.GooglePlayServicesUtil.A(Unknown Source)
com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable
(Unknown Source)
com.google.android.gms.maps.internal.u.I(Unknown Source)
com.google.android.gms.maps.internal.u.H(Unknown Source)
com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
com.google.android.gms.maps.MapFragment$b.jz(Unknown Source)
com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
com.google.android.gms.dynamic.a.a(Unknown Source)
com.google.android.gms.dynamic.a.onInflate(Unknown Source)
com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
android.app.Activity.onCreateView(Activity.java:4663)
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
09-01 15:19:34.508: E/Trace(826): error opening trace file: No such file or directory (2)
09-01 15:19:35.118: E/AndroidRuntime(826): FATAL EXCEPTION: main
09-01 15:19:35.118: E/AndroidRuntime(826): java.lang.RuntimeException:
Unable to start activity ComponentInfo{myapp/myapp.MainActivity}: android.view.InflateException:
Binary XML file line #2: Error inflating class fragment
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
android.app.ActivityThread.access$600(ActivityThread.java:130)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:137)
android.app.ActivityThread.main(ActivityThread.java:4745)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
dalvik.system.NativeStart.main(Native Method)
09-01 15:19:35.118: E/AndroidRuntime(826): Caused by: android.view.InflateException: Binary XML
file line #2: Error inflating class fragment
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
android.view.LayoutInflater.inflate(LayoutInflater.java:466)
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
android.view.LayoutInflater.inflate(LayoutInflater.java:352)
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
android.app.Activity.setContentView(Activity.java:1867)
android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
android.support.v7.app.ActionBarActivityDelegateICS.setContentView
(ActionBarActivityDelegateICS.java:110)
android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
myapp.MainActivity.onCreate(MainActivity.java:14)
android.app.Activity.performCreate(Activity.java:5008)
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
09-01 15:19:35.118: E/AndroidRuntime(826): ... 11 more
09-01 15:19:35.118: E/AndroidRuntime(826): Caused by: java.lang.IllegalStateException:
The meta- data tag in your app's AndroidManifest.xml does not
have the right value. Expected 5089000 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" />
com.google.android.gms.common.GooglePlayServicesUtil.A(Unknown Source)
com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailabl
(Unknown Source)
com.google.android.gms.maps.internal.u.I(Unknown Source)
com.google.android.gms.maps.internal.u.H(Unknown Source)
com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
com.google.android.gms.maps.MapFragment$b.jz(Unknown Source)
com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
com.google.android.gms.dynamic.a.a(Unknown Source)
com.google.android.gms.dynamic.a.onInflate(Unknown Source)
com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
android.app.Activity.onCreateView(Activity.java:4663)
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
09-01 15:27:57.068: E/Trace(865): error opening trace file: No such file or directory (2)
09-01 15:27:57.748: E/AndroidRuntime(865): FATAL EXCEPTION: main
09-01 15:27:57.748: E/AndroidRuntime(865): java.lang.RuntimeException:
Unable to start activity ComponentInfo{myapp/myapp.MainActivity}:
android.view.InflateException: Binary XML file line #2: Error inflating class fragment
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
android.app.ActivityThread.access$600(ActivityThread.java:130)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:137)
android.app.ActivityThread.main(ActivityThread.java:4745)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
dalvik.system.NativeStart.main(Native Method)
09-01 15:27:57.748: E/AndroidRuntime(865): Caused by: android.view.InflateException: Binary XML
file line #2: Error inflating class fragment
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
android.view.LayoutInflater.inflate(LayoutInflater.java:466)
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
android.view.LayoutInflater.inflate(LayoutInflater.java:352)
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
android.app.Activity.setContentView(Activity.java:1867)
android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
android.support.v7.app.ActionBarActivityDelegateICS.setContentView
(ActionBarActivityDelegateICS.java:110)
android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
myapp.MainActivity.onCreate(MainActivity.java:14)
android.app.Activity.performCreate(Activity.java:5008)
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
09-01 15:27:57.748: E/AndroidRuntime(865): ... 11 more
09-01 15:27:57.748: E/AndroidRuntime(865): Caused by: java.lang.IllegalStateException:
The meta- data tag in your app's AndroidManifest.xml does not have the right value.
Expected 5089000 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" />
com.google.android.gms.common.GooglePlayServicesUtil.A(Unknown Source)
com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable
(Unknown Source)
com.google.android.gms.maps.internal.u.I(Unknown Source)
com.google.android.gms.maps.internal.u.H(Unknown Source)
com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
com.google.android.gms.maps.MapFragment$b.jz(Unknown Source)
com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
com.google.android.gms.dynamic.a.a(Unknown Source)
com.google.android.gms.dynamic.a.onInflate(Unknown Source)
com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
android.app.Activity.onCreateView(Activity.java:4663)
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
09-01 15:27:57.748: E/AndroidRuntime(865): ... 23 more
mmmh... Change
<meta-data android:name="com.google.android.gms.version" android:value="4030500" />
to
<meta-data android:name="com.google.android.gms.version" android:value="5089000" />
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<permission
android:name="com.myapp.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.myapp.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.myapp."Your activity name""
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.API_KEY"
android:value="Your map key" />
</application>
</manifest>
Add the below permission to your Manifest.xml
<permission android:name="com.myapp.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
and replaca the below line:
<uses-permissionandroid:name="com.myapp.providers.gsf.permission.
READ_GSERVICES"/>
via
<uses-permission android:name="com.myapp.providers.gsf.permission.
READ_GSERVICES"/>

Why my app chash when i put Fragment for Google Maps

I tried to run a google map aplication but when i put a map Fragmet in my xml file the app stops. I think the problem is with the fragment map because when i run the app without it, for example add just a button runs perfectly, i also put the manifest to review
here is my java code:
public class Activity2 extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_activity2);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity2, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_activity2,
container, false);
return rootView;
}
}
}
Here is my XML code
<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="com.example.tutorialgooglemaps.Activity2$PlaceholderFragment" >
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
</RelativeLayout>
and myLOGCAT
03-14 00:47:38.619: E/AndroidRuntime(3717): FATAL EXCEPTION: main
03-14 00:47:38.619: E/AndroidRuntime(3717): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.tutorialgooglemaps/com.example.tutorialgooglemaps.Activity2}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
03-14 00:47:38.619: E/AndroidRuntime(3717): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1970)
03-14 00:47:38.619: E/AndroidRuntime(3717): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
03-14 00:47:38.619: E/AndroidRuntime(3717): at android.app.ActivityThread.access$600(ActivityThread.java:128)
03-14 00:47:38.619: E/AndroidRuntime(3717): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
03-14 00:47:38.619: E/AndroidRuntime(3717): at android.os.Handler.dispatchMessage(Handler.java:99)
03-14 00:47:38.619: E/AndroidRuntime(3717): at android.os.Looper.loop(Looper.java:137)
03-14 00:47:38.619: E/AndroidRuntime(3717): at android.app.ActivityThread.main(ActivityThread.java:4517)
03-14 00:47:38.619: E/AndroidRuntime(3717): at java.lang.reflect.Method.invokeNative(Native Method)
03-14 00:47:38.619: E/AndroidRuntime(3717): at java.lang.reflect.Method.invoke(Method.java:511)
03-14 00:47:38.619: E/AndroidRuntime(3717): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
03-14 00:47:38.619: E/AndroidRuntime(3717): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
03-14 00:47:38.619: E/AndroidRuntime(3717): at dalvik.system.NativeStart.main(Native Method)
03-14 00:47:38.619: E/AndroidRuntime(3717): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
03-14 00:47:38.619: E/AndroidRuntime(3717): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
03-14 00:47:38.619: E/AndroidRuntime(3717): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
03-14 00:47:38.619: E/AndroidRuntime(3717): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
03-14 00:47:38.619: E/AndroidRuntime(3717): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
03-14 00:47:38.619: E/AndroidRuntime(3717): at com.example.tutorialgooglemaps.Activity2$PlaceholderFragment.onCreateView(Activity2.java:59)
03-14 00:47:38.619: E/AndroidRuntime(3717): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
03-14 00:47:38.619: E/AndroidRuntime(3717): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:927)
03-14 00:47:38.619: E/AndroidRuntime(3717): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
03-14 00:47:38.619: E/AndroidRuntime(3717): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
03-14 00:47:38.619: E/AndroidRuntime(3717): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
03-14 00:47:38.619: E/AndroidRuntime(3717): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:570)
03-14 00:47:38.619: E/AndroidRuntime(3717): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1137)
03-14 00:47:38.619: E/AndroidRuntime(3717): at android.app.Activity.performStart(Activity.java:4480)
03-14 00:47:38.619: E/AndroidRuntime(3717): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1943)
03-14 00:47:38.619: E/AndroidRuntime(3717): ... 11 more
03-14 00:47:38.619: E/AndroidRuntime(3717): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4242000 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" />
03-14 00:47:38.619: E/AndroidRuntime(3717): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
03-14 00:47:38.619: E/AndroidRuntime(3717): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
03-14 00:47:38.619: E/AndroidRuntime(3717): at com.google.android.gms.maps.internal.q.v(Unknown Source)
03-14 00:47:38.619: E/AndroidRuntime(3717): at com.google.android.gms.maps.internal.q.u(Unknown Source)
03-14 00:47:38.619: E/AndroidRuntime(3717): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
03-14 00:47:38.619: E/AndroidRuntime(3717): at com.google.android.gms.maps.SupportMapFragment$b.ex(Unknown Source)
03-14 00:47:38.619: E/AndroidRuntime(3717): at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
03-14 00:47:38.619: E/AndroidRuntime(3717): at com.google.android.gms.dynamic.a.a(Unknown Source)
03-14 00:47:38.619: E/AndroidRuntime(3717): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
03-14 00:47:38.619: E/AndroidRuntime(3717): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
03-14 00:47:38.619: E/AndroidRuntime(3717): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:290)
03-14 00:47:38.619: E/AndroidRuntime(3717): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
03-14 00:47:38.619: E/AndroidRuntime(3717): ... 24 more
here is the manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.tutorialgooglemaps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<permission
android:name="org.example.ejemplogooglemaps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="org.example.ejemplogooglemaps.permission.MAPS_RECEIVE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.tutorialgooglemaps.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.API_KEY"
android:value="AIzaSyDrcKDGxUgl0Ps4u2ptOsIUCI6ooXmZ0RU" />
<activity
android:name="com.example.tutorialgooglemaps.Activity2"
android:label="#string/title_activity_activity2" >
</activity>
</application>
</manifest>
Your logcat clearly said
03-14 00:47:38.619: E/AndroidRuntime(3717): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4242000 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" />
Add the Google Play services version to your app's manifest
Edit your application's AndroidManifest.xml file, and add the
following declaration within the element. This embeds the version of
Google Play services that the app was compiled with.
You need to add <meta-data> under <application> tag into your AndroidManifest.xml
....<application>
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
This is because latest google play services requires a version name, which is to be mentioned using <meta-data .. /> inside AndroidManifest.xml
Update: build your manifest.xml like:
....<application>
..............
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDrcKDGxUgl0Ps4u2ptOsIUCI6ooXmZ0RU" />
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>

Error inflating class fragment on Google Maps V2

I develop an application and I need to see the Google Maps v2.
The main class is:
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.app.Activity;
public class MapsV2 extends FragmentActivity {
private GoogleMap mMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mapsv2);
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
final LatLng CIU = new LatLng(35.21843892856462, 33.41662287712097);
Marker ciu = mMap.addMarker(new MarkerOptions()
.position(CIU).title("My Office"));
}
#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_page_option_menu, menu);
return true;
}
}
And the XML is:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"
android:name="com.app.reminder.MapsV2"/>
So, when I run it on my device I've got error message:
02-18 14:20:37.596: E/AndroidRuntime(30383): FATAL EXCEPTION: main
02-18 14:20:37.596: E/AndroidRuntime(30383): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.reminder/com.app.reminder.MapsV2}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.app.ActivityThread.access$600(ActivityThread.java:140)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.os.Handler.dispatchMessage(Handler.java:99)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.os.Looper.loop(Looper.java:137)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.app.ActivityThread.main(ActivityThread.java:4898)
02-18 14:20:37.596: E/AndroidRuntime(30383): at java.lang.reflect.Method.invokeNative(Native Method)
02-18 14:20:37.596: E/AndroidRuntime(30383): at java.lang.reflect.Method.invoke(Method.java:511)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
02-18 14:20:37.596: E/AndroidRuntime(30383): at dalvik.system.NativeStart.main(Native Method)
02-18 14:20:37.596: E/AndroidRuntime(30383): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.app.Activity.setContentView(Activity.java:1924)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.app.reminder.MapsV2.onCreate(MapsV2.java:22)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.app.Activity.performCreate(Activity.java:5206)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
02-18 14:20:37.596: E/AndroidRuntime(30383): ... 11 more
02-18 14:20:37.596: E/AndroidRuntime(30383): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4132500 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" />
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.google.android.gms.maps.internal.q.v(Unknown Source)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.google.android.gms.maps.internal.q.u(Unknown Source)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.google.android.gms.maps.SupportMapFragment$b.eb(Unknown Source)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.google.android.gms.dynamic.a.a(Unknown Source)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:290)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
02-18 14:20:37.596: E/AndroidRuntime(30383): ... 20 more
The manifest is:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app.reminder"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="15" />
<permission
android:name="com.app.reminder.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.app.reminder.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:name="com.app.reminder.InfoManager">
>
<activity
android:name="SplashScreen"
android:theme="#android:style/Theme.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="MapsV2"></activity><uses-library android:name="com.google.android.maps"
/>
<uses-library android:name="com.google.android.maps" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyBDtXP5sYucD8z5pjaJFuvt43sLWOGzyuQ" />
<activity android:name="MapsV2"></activity>
</application>
</manifest>
I tried all the options in the answers in StackOverFlow.
The log is quite clear, you are missing this line in your manifest:
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
As you can read at the end of this line:
Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4132500 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" />
Also, take care to have the last version of Google Play services(version 13 or more), and not Google Play services for Froyo, who doesn't contain that parameter.
You should replace this
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
With
mMap = ((SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map)).getMap();
Replace your Fragment
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
In manifest.xml
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
Activity class
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GoogleMap gMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

android manifest being choosey

Ok, so I've got my Android application and it wont boot with a "unable to instantiate activity ComponentInfo{}" error, basically theres something wrong in my manifest file that won't let the application launch the first activity. I made a new but essentially duplicated project (manually copying across the Java+XML code for Main, second + third 'tester' activities, and of course Strings). I left the manifest of the new project as it is but added the activity lines for the tester. I wanted everything as stock basically so nothing could go wrong, and nothing did, the application loaded on emulator and my phone alright.
So I copy the new manifest to my old project in an effort to 'default' it, and I copy and pasted the tester activity code that was already there and worked, for the other 3 activity's. Suddenly it doesn't want to work. Everything is there, but what's the problem? (note the icon drawable is changed but that's nothing to do with it). All the activity names match up to package names and whatnot. Could this be a bug? I honestly cannot find anything wrong.
Duplicate (+ working) code
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/logo3"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.ollygrov.bakerspride.Main"
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="com.ollygrov.bakerspride.Cal"
android:label="#string/title_activity_cal" >
</activity>
<activity
android:name="com.ollygrov.bakerspride.Breads"
android:label="#string/title_activity_breads" >
</activity>
</application>
Old (+ not working) code
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.ollygrov.bakerspride.Main"
android:label="#string/app_title" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.ollygrov.bakerspride.Cal"
android:label="#string/title_activity_cal" >
</activity>
<activity
android:name="com.ollygrov.bakerspride.Breads"
android:label="#string/title_activity_breads" >
</activity>
<activity
android:name="com.ollygrov.bakerspride.Gal"
android:label="#string/title_activity_gal" >
</activity>
<activity
android:name="com.ollygrov.bakerspride.Tut"
android:label="#string/title_activity_tut" >
</activity>
<activity
android:name="com.ollygrov.bakerspride.Rec"
android:label="#string/title_activity_rec" >
</activity>
</application>
EDIT: I just copied and pasted the codes into the search bar on Chrome (changing the droid:icon and droid:label to fit) and they are exactly the same!! What?! Am I not allowed to have 6 activities or something?
Errors:
09-04 11:33:04.895: E/AndroidRuntime(717): FATAL EXCEPTION: main
09-04 11:33:04.895: E/AndroidRuntime(717): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.ollygrov.bakerspride/com.ollygrov.bakerspride.Main}: java.lang.NullPointerException
09-04 11:33:04.895: E/AndroidRuntime(717): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
09-04 11:33:04.895: E/AndroidRuntime(717): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
09-04 11:33:04.895: E/AndroidRuntime(717): at android.app.ActivityThread.access$600(ActivityThread.java:130)
09-04 11:33:04.895: E/AndroidRuntime(717): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
09-04 11:33:04.895: E/AndroidRuntime(717): at android.os.Handler.dispatchMessage(Handler.java:99)
09-04 11:33:04.895: E/AndroidRuntime(717): at android.os.Looper.loop(Looper.java:137)
09-04 11:33:04.895: E/AndroidRuntime(717): at android.app.ActivityThread.main(ActivityThread.java:4745)
09-04 11:33:04.895: E/AndroidRuntime(717): at java.lang.reflect.Method.invokeNative(Native Method)
09-04 11:33:04.895: E/AndroidRuntime(717): at java.lang.reflect.Method.invoke(Method.java:511)
09-04 11:33:04.895: E/AndroidRuntime(717): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-04 11:33:04.895: E/AndroidRuntime(717): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-04 11:33:04.895: E/AndroidRuntime(717): at dalvik.system.NativeStart.main(Native Method)
09-04 11:33:04.895: E/AndroidRuntime(717): Caused by: java.lang.NullPointerException
09-04 11:33:04.895: E/AndroidRuntime(717): at android.app.Activity.findViewById(Activity.java:1825)
09-04 11:33:04.895: E/AndroidRuntime(717): at com.ollygrov.bakerspride.Main.<init>(Main.java:19)
09-04 11:33:04.895: E/AndroidRuntime(717): at java.lang.Class.newInstanceImpl(Native Method)
09-04 11:33:04.895: E/AndroidRuntime(717): at java.lang.Class.newInstance(Class.java:1319)
09-04 11:33:04.895: E/AndroidRuntime(717): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
09-04 11:33:04.895: E/AndroidRuntime(717): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
09-04 11:33:04.895: E/AndroidRuntime(717): ... 11 more
09-04 11:34:58.665: E/Trace(765): error opening trace file: No such file or directory (2)
09-04 11:34:59.095: D/AndroidRuntime(765): Shutting down VM
09-04 11:34:59.095: W/dalvikvm(765): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
09-04 11:34:59.114: E/AndroidRuntime(765): FATAL EXCEPTION: main
09-04 11:34:59.114: E/AndroidRuntime(765): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.ollygrov.bakerspride/com.ollygrov.bakerspride.Main}: java.lang.NullPointerException
09-04 11:34:59.114: E/AndroidRuntime(765): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
09-04 11:34:59.114: E/AndroidRuntime(765): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
09-04 11:34:59.114: E/AndroidRuntime(765): at android.app.ActivityThread.access$600(ActivityThread.java:130)
09-04 11:34:59.114: E/AndroidRuntime(765): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
09-04 11:34:59.114: E/AndroidRuntime(765): at android.os.Handler.dispatchMessage(Handler.java:99)
09-04 11:34:59.114: E/AndroidRuntime(765): at android.os.Looper.loop(Looper.java:137)
09-04 11:34:59.114: E/AndroidRuntime(765): at android.app.ActivityThread.main(ActivityThread.java:4745)
09-04 11:34:59.114: E/AndroidRuntime(765): at java.lang.reflect.Method.invokeNative(Native Method)
09-04 11:34:59.114: E/AndroidRuntime(765): at java.lang.reflect.Method.invoke(Method.java:511)
09-04 11:34:59.114: E/AndroidRuntime(765): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-04 11:34:59.114: E/AndroidRuntime(765): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-04 11:34:59.114: E/AndroidRuntime(765): at dalvik.system.NativeStart.main(Native Method)
09-04 11:34:59.114: E/AndroidRuntime(765): Caused by: java.lang.NullPointerException
09-04 11:34:59.114: E/AndroidRuntime(765): at android.app.Activity.findViewById(Activity.java:1825)
09-04 11:34:59.114: E/AndroidRuntime(765): at com.ollygrov.bakerspride.Main.<init>(Main.java:19)
09-04 11:34:59.114: E/AndroidRuntime(765): at java.lang.Class.newInstanceImpl(Native Method)
09-04 11:34:59.114: E/AndroidRuntime(765): at java.lang.Class.newInstance(Class.java:1319)
09-04 11:34:59.114: E/AndroidRuntime(765): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
09-04 11:34:59.114: E/AndroidRuntime(765): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
The problem is your Main Constructor:
09-04 11:33:04.895: E/AndroidRuntime(717): Caused by: java.lang.NullPointerException
09-04 11:33:04.895: E/AndroidRuntime(717): at android.app.Activity.findViewById(Activity.java:1825)
09-04 11:33:04.895: E/AndroidRuntime(717): at com.ollygrov.bakerspride.Main.<init>(Main.java:19)
In line 19 of Main.java you are trying to call findViewById() which will obviously not work. It is way to early to call such code in the constructor.
My best guess is, that you need to move EVERYTHING from the cronstructor to onCreate() of the Activity.
Normally you don't need a custom constructor in Activities or Fragments.

Categories

Resources