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"/>
Related
I'm new in Android development. I want to add Google maps to my application. I have done lots of searches but still the same problem arises when I run the application "Unfortunately , application has stopped"
So this is my java class
package com.example.hellomap;
import com.google.android.maps.MapView;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_main);
MapView map =(MapView) findViewById(R.id.map);
}
}
the xml file :
<?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.MapFragment"/>
and the Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hellomap"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<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="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<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" >
<uses-library android:name="com.google.android.maps"/>
<activity
android:name="com.example.hellomap.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="AIzaSyCKSp9pb7g8Wkga2SgeoT_MSe0JG59DkSU" />
</application>
</manifest>
The LogCat shows:
04-03 13:45:42.574: E/AndroidRuntime(1164): FATAL EXCEPTION: main
04-03 13:45:42.574: E/AndroidRuntime(1164): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.hellomap/com.example.hellomap.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.ActivityThread.access$600(ActivityThread.java:130)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.os.Handler.dispatchMessage(Handler.java:99)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.os.Looper.loop(Looper.java:137)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.ActivityThread.main(ActivityThread.java:4745)
04-03 13:45:42.574: E/AndroidRuntime(1164): at java.lang.reflect.Method.invokeNative(Native Method)
04-03 13:45:42.574: E/AndroidRuntime(1164): at java.lang.reflect.Method.invoke(Method.java:511)
04-03 13:45:42.574: E/AndroidRuntime(1164): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
04-03 13:45:42.574: E/AndroidRuntime(1164): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
04-03 13:45:42.574: E/AndroidRuntime(1164): at dalvik.system.NativeStart.main(Native Method)
04-03 13:45:42.574: E/AndroidRuntime(1164): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
04-03 13:45:42.574: E/AndroidRuntime(1164): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.Activity.setContentView(Activity.java:1867)
04-03 13:45:42.574: E/AndroidRuntime(1164): at com.example.hellomap.MainActivity.onCreate(MainActivity.java:23)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.Activity.performCreate(Activity.java:5008)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
04-03 13:45:42.574: E/AndroidRuntime(1164): ... 11 more
04-03 13:45:42.574: E/AndroidRuntime(1164): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.Fragment.instantiate(Fragment.java:584)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.Fragment.instantiate(Fragment.java:552)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.Activity.onCreateView(Activity.java:4656)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
04-03 13:45:42.574: E/AndroidRuntime(1164): ... 20 more
04-03 13:45:42.574: E/AndroidRuntime(1164): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment
04-03 13:45:42.574: E/AndroidRuntime(1164): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
04-03 13:45:42.574: E/AndroidRuntime(1164): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
04-03 13:45:42.574: E/AndroidRuntime(1164): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.Fragment.instantiate(Fragment.java:574)
04-03 13:45:42.574: E/AndroidRuntime(1164): ... 23 more
04-03 13:50:42.626: I/Process(1164): Sending signal. PID: 1164 SIG: 9
Thanks for help :)
EXCEPTION :- ClassNotFoundException
please check GooglePlayService Library Project First.
Second Thing You Can Not Type Cast Fragment To Map View, please read this
Update:-
Follow The Step:-
1)Create New Project
2)Import GooglePlayService Library project into Your Workspace.
3)assign Google play Service library project as library project to your project
4)now add Map Fragment/Supported Map Fragment into your activity layout file
5)make sure this class found
how to check==>press control Key from keyboard and click on class name id you found class then it's okay other wise fix it first.
i prefer to use Supported Fragment.
6)define all permission as describe in link i posted previously.
6)now its time to generate api key for map ,follow the step from given link.
Thanks i hope its help
I have tried a small example in Google map. I have got the API key but when I run the project, it displays the following errors. I have also imported Google play services.
My XML file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
My Java
package com.arun.maps;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.widget.Toast;
public class GoogleMapS extends FragmentActivity {
private GoogleMap googleMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.google_map);
try {
// Loading map
initilizeMap();
} catch (Exception e) {
e.printStackTrace();
}
}
private void initilizeMap() {
if (googleMap == null) {
googleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(
R.id.map)).getMap();
// check if map is created successfully or not
if (googleMap == null) {
Toast.makeText(getApplicationContext(),
"Sorry! unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}
#Override
protected void onResume() {
super.onResume();
initilizeMap();
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.google_map, menu);
return true;
}
}
Android manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.arun.maps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET" />
<!-- Required OpenGL ES 2.0. for Maps V2 -->
<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" >
<uses-library android:name="com.google.android.maps" />
<activity
android:name="com.arun.maps.GoogleMapS"
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="
AIzaSyBn3b2eGABl1JL-xXKe1H_uf4UtPRUUAwY" />
</application>
</manifest>
Error:
04-02 17:21:39.355: E/AndroidRuntime(719): FATAL EXCEPTION: main
04-02 17:21:39.355: E/AndroidRuntime(719): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.arun.maps/com.arun.maps.GoogleMapS}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
04-02 17:21:39.355: E/AndroidRuntime(719): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.os.Handler.dispatchMessage(Handler.java:99)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.os.Looper.loop(Looper.java:130)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-02 17:21:39.355: E/AndroidRuntime(719): at java.lang.reflect.Method.invokeNative(Native Method)
04-02 17:21:39.355: E/AndroidRuntime(719): at java.lang.reflect.Method.invoke(Method.java:507)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-02 17:21:39.355: E/AndroidRuntime(719): at dalvik.system.NativeStart.main(Native Method)
04-02 17:21:39.355: E/AndroidRuntime(719): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
04-02 17:21:39.355: E/AndroidRuntime(719): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.app.Activity.setContentView(Activity.java:1657)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.arun.maps.GoogleMapS.onCreate(GoogleMapS.java:16)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
04-02 17:21:39.355: E/AndroidRuntime(719): ... 11 more
04-02 17:21:39.355: E/AndroidRuntime(719): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4323000 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" />
04-02 17:21:39.355: E/AndroidRuntime(719): at com.google.android.gms.common.GooglePlayServicesUtil.t(Unknown Source)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.google.android.gms.maps.internal.q.B(Unknown Source)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.google.android.gms.maps.internal.q.A(Unknown Source)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.google.android.gms.maps.SupportMapFragment$b.gW(Unknown Source)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.google.android.gms.dynamic.a.a(Unknown Source)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:290)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
04-02 17:21:39.355: E/AndroidRuntime(719): ... 20 more
Add this in manifest file's application tag.
<!-- Required after latest Google Play Services update -->
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
Add this in manifest file inside your application tag:
<meta-data
android:name="com.google.android.gms.version"
android:value="4242000" />
i'am new in Android programming i have a problem. When my code running i give error "Unfortunately [app] has Stopped" in my device screen.
This is my Activity
package com.android.markermap;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
public class MainActivity extends Activity {
static final LatLng BANDUNG = new LatLng(-6.904955,107.61034);
static final LatLng BOGOR = new LatLng(-6.589581,106.799755);
private GoogleMap map;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
Marker bandung = map.addMarker(new MarkerOptions().position(BANDUNG).title("Berat"));
Marker bogor = map.addMarker(new MarkerOptions().position(BOGOR).title("Ringan").snippet("Kiel is cool"));
// Move the camera instantly to hamburg with a zoom of 15.
map.moveCamera(CameraUpdateFactory.newLatLngZoom(BANDUNG, 12));
// Zoom in, animating the camera.
map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
This is my layout 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"
tools:context=".MainActivity" >
<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 manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.markermap"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="16" />
<permission
android:name="com.android.markermap.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="com.android.markermap.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.android.markermap.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="AIzaSyC-0N7OEKJmId5HnKYNsbU6IBaSIgiF7Lc" />
</application>
</manifest>
And this is my error code
11-30 23:39:58.071: W/dalvikvm(16870): threadid=1: thread exiting with uncaught exception (group=0x40c64438)
11-30 23:39:58.071: E/AndroidRuntime(16870): FATAL EXCEPTION: main
11-30 23:39:58.071: E/AndroidRuntime(16870): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.markermap/com.android.markermap.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2067)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2092)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.app.ActivityThread.access$600(ActivityThread.java:133)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.os.Handler.dispatchMessage(Handler.java:99)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.os.Looper.loop(Looper.java:137)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.app.ActivityThread.main(ActivityThread.java:4810)
11-30 23:39:58.071: E/AndroidRuntime(16870): at java.lang.reflect.Method.invokeNative(Native Method)
11-30 23:39:58.071: E/AndroidRuntime(16870): at java.lang.reflect.Method.invoke(Method.java:511)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
11-30 23:39:58.071: E/AndroidRuntime(16870): at dalvik.system.NativeStart.main(Native Method)
11-30 23:39:58.071: E/AndroidRuntime(16870): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:262)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.app.Activity.setContentView(Activity.java:1867)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.android.markermap.MainActivity.onCreate(MainActivity.java:23)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.app.Activity.performCreate(Activity.java:5008)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2031)
11-30 23:39:58.071: E/AndroidRuntime(16870): ... 11 more
11-30 23:39:58.071: E/AndroidRuntime(16870): 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" />
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.google.android.gms.maps.internal.q.v(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.google.android.gms.maps.internal.q.u(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.google.android.gms.maps.MapFragment$b.cE(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.google.android.gms.dynamic.a.a(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.app.Activity.onCreateView(Activity.java:4663)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
11-30 23:39:58.071: E/AndroidRuntime(16870): ... 21 more
Anyonee have ide for this problem?
i'am very confuse, i hope u can solve this problem.
actually reading the error help a lot you know
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" />
Your code is fine but for Google play service revision 13 you should have to add one more meta tag in your manifest.xml.Insert it inside your application tag.So there will be two meta tags in your application tag.If you still need any help.Just follow this link
<meta-data android:name="com.google.android.gms.version" android:value="4030500" />
I have a SupportMapFragment being used and in every device i've tested it on it has worked fine. I got an error report for a java.io.FileNotFoundException with the following:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.koosprozinski.westernwheels/com.koosprozinski.westernwheels.MainActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2073)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2098)
at android.app.ActivityThread.access$600(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1204)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4945)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:561)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:408)
at android.app.Activity.setContentView(Activity.java:2050)
at com.koosprozinski.westernwheels.MainActivity.onCreate(MainActivity.java:40)
at android.app.Activity.performCreate(Activity.java:5202)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1082)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2037)
... 11 more
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/maps_btn_myl.xml from drawable resource ID #0x7f020115
at android.content.res.Resources.loadDrawable(Resources.java:1957)
at android.content.res.Resources.getDrawable(Resources.java:673)
at maps.ai.a.c(Unknown Source)
at maps.af.al.a(Unknown Source)
at maps.af.be.a(Unknown Source)
at maps.af.bd.a(Unknown Source)
at cmi.onTransact(SourceFile:107)
at android.os.Binder.transact(Binder.java:326)
at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onCreateView(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment$a.onCreateView(Unknown Source)
at com.google.android.gms.dynamic.a$4.b(Unknown Source)
at com.google.android.gms.dynamic.a.a(Unknown Source)
at com.google.android.gms.dynamic.a.onCreateView(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1460)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:884)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1066)
at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1168)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:280)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
... 21 more
Caused by: android.content.res.Resources$NotFoundException: File res/drawable-hdpi-v14/maps_btn_myl_pressed.png from drawable resource ID #0x7f020117
at android.content.res.Resources.loadDrawable(Resources.java:1974)
at android.content.res.Resources.getDrawable(Resources.java:673)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:173)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:881)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:818)
at android.content.res.Resources.loadDrawable(Resources.java:1954)
... 40 more
Caused by: java.io.FileNotFoundException: res/drawable-hdpi-v14/maps_btn_myl_pressed.png
at android.content.res.AssetManager.openNonAssetNative(Native Method)
at android.content.res.AssetManager.openNonAsset(AssetManager.java:407)
at android.content.res.Resources.loadDrawable(Resources.java:1966)
... 45 more
Here is my main activity xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
What exactly could be causing this? As far as I am aware, the vast majority of users are not experiencing this and I can't think of any way to try and replicate it.
Try the following, it worked for me:
<application>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="API KEY" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
I suggest you to make like this:
<fragment
android:id="#+id/map"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Not android:name. Let me know if it works.
And here is the solution! NullPointerException from Google maps
Insert the SD card if you don't have an internal one! Google din't fix that problem since 2013.
On your main activity xml, change android:name="com.google.android.gms.maps.SupportMapFragment"
to this :
class="com.google.android.gms.maps.SupportMapFragment"
am getting this exception:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{business.premium/business.premium.Problemio}:
java.lang.ClassNotFoundException: business.premium.Problemio
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: business.premium.Problemio
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
... 11 more
java.lang.ClassNotFoundException: business.premium.Problemio
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
it says that class is not there, but it IS there. I tried to configure things in my project's build path, but not too sure what to tweak there.
And here is how I start my Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="business.premium"
android:versionCode="1"
android:versionName="1.0" >
<supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true"/>
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15"/>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/CustomTheme"
android:name="MyApplication"
android:debuggable="true">
<activity
android:name=".Problemio"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Any thoughts on how to solve this, or what to look into? Thanks!
Its because you specified the "android:name" attribute in the application node in the manifest file.
Do not use the android:name attribute!
It, misleadingly, does not have anything to do with the name of your app and is actually the name of an extra class to load before loading your application. That's why you are getting the ClassNotFoundException.
Remove it and it should work:
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:description="#string/help_text" >
This answer is taken from: java.lang.ClassNotFoundException on working app