I'm using google maps v2 in my application. The app crashes as soon as it starts. Min SDK version is 8 and Max is 19. I can't get what the error is. Below is my LogCat and Code, Please Help
Log
03-10 16:17:37.977: E/AndroidRuntime(24296): FATAL EXCEPTION: main
03-10 16:17:37.977: E/AndroidRuntime(24296): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.appscourt.earth.map.location/com.appscourt.earth.map.location.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
03-10 16:17:37.977: E/AndroidRuntime(24296): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2136)
03-10 16:17:37.977: E/AndroidRuntime(24296): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2174)
03-10 16:17:37.977: E/AndroidRuntime(24296): at android.app.ActivityThread.access$700(ActivityThread.java:141)
03-10 16:17:37.977: E/AndroidRuntime(24296): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1267)
03-10 16:17:37.977: E/AndroidRuntime(24296): at android.os.Handler.dispatchMessage(Handler.java:99)
03-10 16:17:37.977: E/AndroidRuntime(24296): at android.os.Looper.loop(Looper.java:137)
03-10 16:17:37.977: E/AndroidRuntime(24296): at android.app.ActivityThread.main(ActivityThread.java:5059)
03-10 16:17:37.977: E/AndroidRuntime(24296): at java.lang.reflect.Method.invokeNative(Native Method)
03-10 16:17:37.977: E/AndroidRuntime(24296): at java.lang.reflect.Method.invoke(Method.java:511)
03-10 16:17:37.977: E/AndroidRuntime(24296): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
03-10 16:17:37.977: E/AndroidRuntime(24296): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
03-10 16:17:37.977: E/AndroidRuntime(24296): at dalvik.system.NativeStart.main(Native Method)
03-10 16:17:37.977: E/AndroidRuntime(24296): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
03-10 16:17:37.977: E/AndroidRuntime(24296): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
03-10 16:17:37.977: E/AndroidRuntime(24296): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
03-10 16:17:37.977: E/AndroidRuntime(24296): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
03-10 16:17:37.977: E/AndroidRuntime(24296): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
03-10 16:17:37.977: E/AndroidRuntime(24296): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
03-10 16:17:37.977: E/AndroidRuntime(24296): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:260)
03-10 16:17:37.977: E/AndroidRuntime(24296): at android.app.Activity.setContentView(Activity.java:1893)
03-10 16:17:37.977: E/AndroidRuntime(24296): at com.appscourt.earth.map.location.MainActivity.onCreate(MainActivity.java:31)
03-10 16:17:37.977: E/AndroidRuntime(24296): at android.app.Activity.performCreate(Activity.java:5058)
03-10 16:17:37.977: E/AndroidRuntime(24296): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
03-10 16:17:37.977: E/AndroidRuntime(24296): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
03-10 16:17:37.977: E/AndroidRuntime(24296): ... 11 more
03-10 16:17:37.977: E/AndroidRuntime(24296): Caused by: java.lang.SecurityException: The Maps API requires the additional following permissions to be set in the AndroidManifest.xml to ensure a correct behavior:
03-10 16:17:37.977: E/AndroidRuntime(24296): <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
03-10 16:17:37.977: E/AndroidRuntime(24296): at maps.e.ch.a(Unknown Source)
03-10 16:17:37.977: E/AndroidRuntime(24296): at maps.e.ay.a(Unknown Source)
03-10 16:17:37.977: E/AndroidRuntime(24296): at maps.e.ay.a(Unknown Source)
03-10 16:17:37.977: E/AndroidRuntime(24296): at maps.e.al.a(Unknown Source)
03-10 16:17:37.977: E/AndroidRuntime(24296): at maps.e.bg.a(Unknown Source)
03-10 16:17:37.977: E/AndroidRuntime(24296): at maps.e.bf.a(Unknown Source)
03-10 16:17:37.977: E/AndroidRuntime(24296): at eio.onTransact(SourceFile:107)
03-10 16:17:37.977: E/AndroidRuntime(24296): at android.os.Binder.transact(Binder.java:326)
03-10 16:17:37.977: E/AndroidRuntime(24296): at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onCreateView(Unknown Source)
03-10 16:17:37.977: E/AndroidRuntime(24296): at com.google.android.gms.maps.SupportMapFragment$a.onCreateView(Unknown Source)
03-10 16:17:37.977: E/AndroidRuntime(24296): at com.google.android.gms.dynamic.a$4.b(Unknown Source)
03-10 16:17:37.977: E/AndroidRuntime(24296): at com.google.android.gms.dynamic.a.a(Unknown Source)
03-10 16:17:37.977: E/AndroidRuntime(24296): at com.google.android.gms.dynamic.a.onCreateView(Unknown Source)
03-10 16:17:37.977: E/AndroidRuntime(24296): at com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)
03-10 16:17:37.977: E/AndroidRuntime(24296): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
03-10 16:17:37.977: E/AndroidRuntime(24296): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:900)
03-10 16:17:37.977: E/AndroidRuntime(24296): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1082)
03-10 16:17:37.977: E/AndroidRuntime(24296): at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1184)
03-10 16:17:37.977: E/AndroidRuntime(24296): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:291)
03-10 16:17:37.977: E/AndroidRuntime(24296): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
XML File
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="35dip"
android:name="com.google.android.gms.maps.SupportMapFragment" />
MainActivity.Java
public class MainActivity extends FragmentActivity implements
LoaderCallbacks<Cursor> {
....
private void initializeMap() {
if (gMap == null) {
gMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(
R.id.map)).getMap();
// check if map is created successfully or not
if (gMap == null) {
Toast.makeText(getApplicationContext(),
"Sorry! unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}
Your logcat clearly said:
Caused by: java.lang.SecurityException: The Maps API requires the additional following permissions to be set in the AndroidManifest.xml to
ensure a correct behavior: 03-10 16:17:37.977: E/AndroidRuntime(24296):
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
You need to add this permission in your manifest.xml
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
For the Internet security reason you need to add this permission to manifest file.
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
To inflate Google Map you need to Add below permission in your manifest. It clearly defined in your logcat error.
Caused by: java.lang.SecurityException: The Maps API requires the additional following permissions to be set in the AndroidManifest.xml to ensure a correct behavior:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Also make sure you have added the below permissions also
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!-- External storage for caching. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Related
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"/>
i want to deploy google maps into my android application. i followed a step-by-step procedure which i found it here. But when i run the application. I got "Unfortunately your application has stopped error. I followed each step in that document. please let me know the error.
here is my logcat's output
04-18 12:15:30.416: I/Process(1423): Sending signal. PID: 1423 SIG: 9
04-18 12:15:31.676: W/dalvikvm(1443): VFY: unable to resolve static field 2529 (MapAttrs) in Lcom/google/android/gms/R$styleable;
04-18 12:15:31.676: D/dalvikvm(1443): VFY: replacing opcode 0x62 at 0x000e
04-18 12:15:31.686: D/AndroidRuntime(1443): Shutting down VM
04-18 12:15:31.686: W/dalvikvm(1443): threadid=1: thread exiting with uncaught exception (group=0xb1a6cba8)
04-18 12:15:31.726: E/AndroidRuntime(1443): FATAL EXCEPTION: main
04-18 12:15:31.726: E/AndroidRuntime(1443): Process: tarun.ksr.mymap, PID: 1443
04-18 12:15:31.726: E/AndroidRuntime(1443): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
04-18 12:15:31.726: E/AndroidRuntime(1443): at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
04-18 12:15:31.726: E/AndroidRuntime(1443): at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
04-18 12:15:31.726: E/AndroidRuntime(1443): at android.app.Activity.onCreateView(Activity.java:4785)
04-18 12:15:31.726: E/AndroidRuntime(1443): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
04-18 12:15:31.726: E/AndroidRuntime(1443): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
04-18 12:15:31.726: E/AndroidRuntime(1443): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
04-18 12:15:31.726: E/AndroidRuntime(1443): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
04-18 12:15:31.726: E/AndroidRuntime(1443): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
04-18 12:15:31.726: E/AndroidRuntime(1443): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
04-18 12:15:31.726: E/AndroidRuntime(1443): at android.app.Activity.setContentView(Activity.java:1929)
04-18 12:15:31.726: E/AndroidRuntime(1443): at tarun.ksr.mymap.MainActivity.onCreate(MainActivity.java:20)
04-18 12:15:31.726: E/AndroidRuntime(1443): at android.app.Activity.performCreate(Activity.java:5231)
04-18 12:15:31.726: E/AndroidRuntime(1443): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
04-18 12:15:31.726: E/AndroidRuntime(1443): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
04-18 12:15:31.726: E/AndroidRuntime(1443): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
04-18 12:15:31.726: E/AndroidRuntime(1443): at android.app.ActivityThread.access$800(ActivityThread.java:135)
04-18 12:15:31.726: E/AndroidRuntime(1443): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
04-18 12:15:31.726: E/AndroidRuntime(1443): at android.os.Handler.dispatchMessage(Handler.java:102)
04-18 12:15:31.726: E/AndroidRuntime(1443): at android.os.Looper.loop(Looper.java:136)
04-18 12:15:31.726: E/AndroidRuntime(1443): at android.app.ActivityThread.main(ActivityThread.java:5017)
04-18 12:15:31.726: E/AndroidRuntime(1443): at java.lang.reflect.Method.invokeNative(Native Method)
04-18 12:15:31.726: E/AndroidRuntime(1443): at java.lang.reflect.Method.invoke(Method.java:515)
04-18 12:15:31.726: E/AndroidRuntime(1443): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
04-18 12:15:31.726: E/AndroidRuntime(1443): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
04-18 12:15:31.726: E/AndroidRuntime(1443): at dalvik.system.NativeStart.main(Native Method)
04-18 12:15:34.846: I/Process(1443): Sending signal. PID: 1443 SIG: 9
Here is my MainActivity.java
package tarun.ksr.mymap;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
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;
public class MainActivity extends Activity {
private GoogleMap mMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
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, menu);
return true;
}
}
MANIFEST :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tarun.ksr.mymap"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<permission
android:name="com.example.androidmapsv2.permission.MAPS_RECEIVE"
android:protectionLevel="signature" >
</permission>
<uses-permission android:name="com.example.androidmapsv2.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.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" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCfVTb5mW1c-q8RdBtX7NJJ0S1KXgkHUP0"/>
<activity
android:name="tarun.ksr.mymap.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>
Add this to the manifest-
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
Also check whether the Google Play Services SDK is configured correctly.
https://developers.google.com/maps/documentation/android/start#getting_the_google_maps_android_api_v2
I'm learning the basics of Android development and I've ran into some issues with setting up the programming environment. Now I've created a new Android Application Project and I'm running it using my phone. When I do, I get an error message on my phone: "Unfortunately, HelloWorld has stopped." and I'm not sure if it's supposed to or not, considering that I've done absolutely nothing to the project files. Here is the LogCat output in its entirety:
03-10 18:34:16.264: D/dalvikvm(2673): Late-enabling CheckJNI
03-10 18:34:16.361: W/dalvikvm(2673): VFY: unable to resolve static field 1559 (ActionBarWindow) in Landroid/support/v7/appcompat/R$styleable;
03-10 18:34:16.361: D/dalvikvm(2673): VFY: replacing opcode 0x62 at 0x0004
03-10 18:34:16.364: D/AndroidRuntime(2673): Shutting down VM
03-10 18:34:16.364: W/dalvikvm(2673): threadid=1: thread exiting with uncaught exception (group=0x416d7d40)
03-10 18:34:16.368: E/AndroidRuntime(2673): FATAL EXCEPTION: main
03-10 18:34:16.368: E/AndroidRuntime(2673): Process: com.example.helloworld, PID: 2673
03-10 18:34:16.368: E/AndroidRuntime(2673): java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable
03-10 18:34:16.368: E/AndroidRuntime(2673): at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:107)
03-10 18:34:16.368: E/AndroidRuntime(2673): at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58)
03-10 18:34:16.368: E/AndroidRuntime(2673): at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
03-10 18:34:16.368: E/AndroidRuntime(2673): at com.example.helloworld.MainActivity.onCreate(MainActivity.java:18)
03-10 18:34:16.368: E/AndroidRuntime(2673): at android.app.Activity.performCreate(Activity.java:5248)
03-10 18:34:16.368: E/AndroidRuntime(2673): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
03-10 18:34:16.368: E/AndroidRuntime(2673): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2173)
03-10 18:34:16.368: E/AndroidRuntime(2673): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269)
03-10 18:34:16.368: E/AndroidRuntime(2673): at android.app.ActivityThread.access$800(ActivityThread.java:139)
03-10 18:34:16.368: E/AndroidRuntime(2673): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
03-10 18:34:16.368: E/AndroidRuntime(2673): at android.os.Handler.dispatchMessage(Handler.java:102)
03-10 18:34:16.368: E/AndroidRuntime(2673): at android.os.Looper.loop(Looper.java:136)
03-10 18:34:16.368: E/AndroidRuntime(2673): at android.app.ActivityThread.main(ActivityThread.java:5102)
03-10 18:34:16.368: E/AndroidRuntime(2673): at java.lang.reflect.Method.invokeNative(Native Method)
03-10 18:34:16.368: E/AndroidRuntime(2673): at java.lang.reflect.Method.invoke(Method.java:515)
03-10 18:34:16.368: E/AndroidRuntime(2673): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
03-10 18:34:16.368: E/AndroidRuntime(2673): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
03-10 18:34:16.368: E/AndroidRuntime(2673): at dalvik.system.NativeStart.main(Native Method)
03-10 18:34:18.259: I/Process(2673): Sending signal. PID: 2673 SIG: 9
03-10 18:36:57.062: W/dalvikvm(2984): VFY: unable to resolve static field 1559 (ActionBarWindow) in Landroid/support/v7/appcompat/R$styleable;
03-10 18:36:57.063: D/dalvikvm(2984): VFY: replacing opcode 0x62 at 0x0004
03-10 18:36:57.064: D/AndroidRuntime(2984): Shutting down VM
03-10 18:36:57.064: W/dalvikvm(2984): threadid=1: thread exiting with uncaught exception (group=0x416d7d40)
03-10 18:36:57.066: E/AndroidRuntime(2984): FATAL EXCEPTION: main
03-10 18:36:57.066: E/AndroidRuntime(2984): Process: com.example.helloworld, PID: 2984
03-10 18:36:57.066: E/AndroidRuntime(2984): java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable
03-10 18:36:57.066: E/AndroidRuntime(2984): at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:107)
03-10 18:36:57.066: E/AndroidRuntime(2984): at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58)
03-10 18:36:57.066: E/AndroidRuntime(2984): at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
03-10 18:36:57.066: E/AndroidRuntime(2984): at com.example.helloworld.MainActivity.onCreate(MainActivity.java:18)
03-10 18:36:57.066: E/AndroidRuntime(2984): at android.app.Activity.performCreate(Activity.java:5248)
03-10 18:36:57.066: E/AndroidRuntime(2984): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
03-10 18:36:57.066: E/AndroidRuntime(2984): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2173)
03-10 18:36:57.066: E/AndroidRuntime(2984): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269)
03-10 18:36:57.066: E/AndroidRuntime(2984): at android.app.ActivityThread.access$800(ActivityThread.java:139)
03-10 18:36:57.066: E/AndroidRuntime(2984): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
03-10 18:36:57.066: E/AndroidRuntime(2984): at android.os.Handler.dispatchMessage(Handler.java:102)
03-10 18:36:57.066: E/AndroidRuntime(2984): at android.os.Looper.loop(Looper.java:136)
03-10 18:36:57.066: E/AndroidRuntime(2984): at android.app.ActivityThread.main(ActivityThread.java:5102)
03-10 18:36:57.066: E/AndroidRuntime(2984): at java.lang.reflect.Method.invokeNative(Native Method)
03-10 18:36:57.066: E/AndroidRuntime(2984): at java.lang.reflect.Method.invoke(Method.java:515)
03-10 18:36:57.066: E/AndroidRuntime(2984): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
03-10 18:36:57.066: E/AndroidRuntime(2984): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
03-10 18:3
6:57.066: E/AndroidRuntime(2984): at dalvik.system.NativeStart.main(Native Method)
So, is this normal behavior or have I done something wrong while setting up Eclipse, etc?
It looks like the Android compatibility library is not correctly configured for your project. In Eclipse, right click on the project in the package explorer and select Android Tools > Add Support Library. After setting up the support library, clean and rebuild your project.
This is normal behavior when reporting an error with your application.
I am developing an android application to show all call logs in the list and when user taps on any call log, i need to open native app's call details screen for that tapped call log.
I have tried following code snippet and it works fine in Emulator (Pure android OS.)
Intent mDetailsIntent = new Intent(Intent.ACTION_VIEW); mDetailsIntent.setType(android.provider.CallLog.Calls.CONTENT_TYPE);
Uri mUri = Uri.withAppendedPath(android.provider.CallLog.Calls.CONTENT_URI, String.valueOf(mCallLog.getId()));
mDetailsIntent.setData(mUri);
startActivity(mDetailsIntent);
But when I run it on Samsung device, it shown the last recent call log's details screen each time regardless of call log id.
And for HTC devices, it throws ActivityNotFoundException.
Following log cat is for HTC device.
**03-10 14:19:00.772: D/LogsFragment(20947): Call log details uri==>content://call_log/calls/62
03-10 14:19:00.782: W/System.err(20947): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=content://call_log/calls/62 }
03-10 14:19:00.792: W/System.err(20947): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1638)
03-10 14:19:00.792: W/System.err(20947): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1510)
03-10 14:19:00.792: W/System.err(20947): at android.app.Activity.startActivityForResult(Activity.java:3258)
03-10 14:19:00.792: W/System.err(20947): at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:833)
03-10 14:19:00.792: W/System.err(20947): at android.support.v4.app.Fragment.startActivity(Fragment.java:856)
03-10 14:19:00.792: W/System.err(20947): at com.cwiker.fragments.LogsFragment.onItemClick(LogsFragment.java:219)
03-10 14:19:00.792: W/System.err(20947): at android.widget.AdapterView.performItemClick(AdapterView.java:292)
03-10 14:19:00.792: W/System.err(20947): at android.widget.AbsListView.performItemClick(AbsListView.java:1099)
03-10 14:19:00.792: W/System.err(20947): at android.widget.ListView.performItemClick(ListView.java:4758)
03-10 14:19:00.792: W/System.err(20947): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2556)
03-10 14:19:00.792: W/System.err(20947): at android.widget.AbsListView$1.run(AbsListView.java:3223)
03-10 14:19:00.792: W/System.err(20947): at android.os.Handler.handleCallback(Handler.java:608)
03-10 14:19:00.802: W/System.err(20947): at android.os.Handler.dispatchMessage(Handler.java:92)
03-10 14:19:00.802: W/System.err(20947): at android.os.Looper.loop(Looper.java:156)
03-10 14:19:00.802: W/System.err(20947): at android.app.ActivityThread.main(ActivityThread.java:4987)
03-10 14:19:00.802: W/System.err(20947): at java.lang.reflect.Method.invokeNative(Native Method)
03-10 14:19:00.802: W/System.err(20947): at java.lang.reflect.Method.invoke(Method.java:511)
03-10 14:19:00.802: W/System.err(20947): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-10 14:19:00.802: W/System.err(20947): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-10 14:19:00.802: W/System.err(20947): at dalvik.system.NativeStart.main(Native Method)**
Please help me to solve this problem.
Thanks.
I am developing a simple Android app which uses the Google Maps API,
I had registered with Google for the API key and added it to my app but I am getting an error:
FATAL EXCEPTION: main
Process: com.s56.maps, PID: 866
12-17 09:28:56.070: E/AndroidRuntime(866): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.s56.maps/com.s56.maps.MainActivity}: android.view.InflateException: Binary XML file line #15: Error inflating class fragment
12-17 09:28:56.070: E/AndroidRuntime(866): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.app.ActivityThread.access$700(ActivityThread.java:135)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.os.Handler.dispatchMessage(Handler.java:102)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.os.Looper.loop(Looper.java:137)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.app.ActivityThread.main(ActivityThread.java:4998)
12-17 09:28:56.070: E/AndroidRuntime(866): at java.lang.reflect.Method.invokeNative(Native Method)
12-17 09:28:56.070: E/AndroidRuntime(866): at java.lang.reflect.Method.invoke(Method.java:515)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
12-17 09:28:56.070: E/AndroidRuntime(866): at dalvik.system.NativeStart.main(Native Method)
12-17 09:28:56.070: E/AndroidRuntime(866): Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class fragment
12-17 09:28:56.070: E/AndroidRuntime(866): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.app.Activity.setContentView(Activity.java:1928)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.s56.maps.MainActivity.onCreate(MainActivity.java:19)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.app.Activity.performCreate(Activity.java:5243)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
12-17 09:28:56.070: E/AndroidRuntime(866): ... 11 more
***12-17 09:28:56.070: E/AndroidRuntime(866): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4030500 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />***
12-17 09:28:56.070: E/AndroidRuntime(866): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.google.android.gms.maps.internal.q.v(Unknown Source)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.google.android.gms.maps.internal.q.u(Unknown Source)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.google.android.gms.maps.MapFragment$b.cE(Unknown Source)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.google.android.gms.dynamic.a.a(Unknown Source)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.app.Activity.onCreateView(Activity.java:4784)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
12-17 09:28:56.070: E/AndroidRuntime(866): ... 21 more
And my XML file is
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.s56.maps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
/>
<permission
android:name="com.s56.maps.permission.MAPS_RECEIVE"
android:protectionLevel="signature"></permission>
<uses-permission
android:name="com.s56.maps.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.WRITE_EXTERNAL_STORAGE"/>
<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.s56.maps.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="A***MY_API_KEY***M"/>
</application>
</manifest>
and my activity_main.xml has
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment"/>
And my main class i.e activity class has,
public class MainActivity extends Activity
{
private GoogleMap mMap;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mMap=
((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
final LatLng CIU = new LatLng(17.426944259701596, 78.5340459823017);
Marker c = mMap.addMarker(new MarkerOptions()
.position(CIU).title("s56 labs"));
}
#Override
public boolean onCreateOptionsMenu(Menu menu)
{
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
} }
I had added Google Play services as library to Eclipse work space.
Kindly help me with this, and I am new to Android.
You must add this to your AndroidManifest.xml:
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />