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" />
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 have been following Googles guide to making an app that allows you to view an app on an Android phone. I have followed many tutorials, but always end up with the same error! I have also searched around the web and figured my error is something to do with the "fragment". Here are my files:
MainActivity.java
package com.example.theapp;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
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.MapFragment"/>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.theapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<permission
android:name="com.example.theapp.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.theapp.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- The following two permissions are not required to use
Google Maps Android API v2, but are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="--REMOVED--"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.theapp.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.gms.version"
android:value="#integer/google_play_services_version" />
</application>
I am using Android 2.3. Here is the log cat messages:
04-02 22:43:45.890: D/AndroidRuntime(23773): Shutting down VM
04-02 22:43:45.890: W/dalvikvm(23773): threadid=1: thread exiting with uncaught exception (group=0x40018578)
04-02 22:43:45.898: E/AndroidRuntime(23773): FATAL EXCEPTION: main
04-02 22:43:45.898: E/AndroidRuntime(23773): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.theapp/com.example.theapp.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
04-02 22:43:45.898: E/AndroidRuntime(23773): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
04-02 22:43:45.898: E/AndroidRuntime(23773): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
04-02 22:43:45.898: E/AndroidRuntime(23773): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-02 22:43:45.898: E/AndroidRuntime(23773): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
04-02 22:43:45.898: E/AndroidRuntime(23773): at android.os.Handler.dispatchMessage(Handler.java:99)
04-02 22:43:45.898: E/AndroidRuntime(23773): at android.os.Looper.loop(Looper.java:130)
04-02 22:43:45.898: E/AndroidRuntime(23773): at android.app.ActivityThread.main(ActivityThread.java:3687)
04-02 22:43:45.898: E/AndroidRuntime(23773): at java.lang.reflect.Method.invokeNative(Native Method)
04-02 22:43:45.898: E/AndroidRuntime(23773): at java.lang.reflect.Method.invoke(Method.java:507)
04-02 22:43:45.898: E/AndroidRuntime(23773): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
04-02 22:43:45.898: E/AndroidRuntime(23773): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
04-02 22:43:45.898: E/AndroidRuntime(23773): at dalvik.system.NativeStart.main(Native Method)
04-02 22:43:45.898: E/AndroidRuntime(23773): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
04-02 22:43:45.898: E/AndroidRuntime(23773): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
04-02 22:43:45.898: E/AndroidRuntime(23773): at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
04-02 22:43:45.898: E/AndroidRuntime(23773): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-02 22:43:45.898: E/AndroidRuntime(23773): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-02 22:43:45.898: E/AndroidRuntime(23773): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:209)
04-02 22:43:45.898: E/AndroidRuntime(23773): at android.app.Activity.setContentView(Activity.java:1657)
04-02 22:43:45.898: E/AndroidRuntime(23773): at com.example.theapp.MainActivity.onCreate(MainActivity.java:11)
04-02 22:43:45.898: E/AndroidRuntime(23773): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-02 22:43:45.898: E/AndroidRuntime(23773): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
04-02 22:43:45.898: E/AndroidRuntime(23773): ... 11 more
04-02 22:43:45.898: E/AndroidRuntime(23773): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.example.theapp-1.apk]
04-02 22:43:45.898: E/AndroidRuntime(23773): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
04-02 22:43:45.898: E/AndroidRuntime(23773): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
04-02 22:43:45.898: E/AndroidRuntime(23773): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
04-02 22:43:45.898: E/AndroidRuntime(23773): at android.view.LayoutInflater.createView(LayoutInflater.java:471)
04-02 22:43:45.898: E/AndroidRuntime(23773): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)
04-02 22:43:45.898: E/AndroidRuntime(23773): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
04-02 22:43:45.898: E/AndroidRuntime(23773): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
04-02 22:43:45.898: E/AndroidRuntime(23773): ... 19 more
04-02 22:55:53.289: D/AndroidRuntime(23942): Shutting down VM
04-02 22:55:53.289: W/dalvikvm(23942): threadid=1: thread exiting with uncaught exception (group=0x40018578)
04-02 22:55:53.304: E/AndroidRuntime(23942): FATAL EXCEPTION: main
04-02 22:55:53.304: E/AndroidRuntime(23942): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.theapp/com.example.theapp.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
04-02 22:55:53.304: E/AndroidRuntime(23942): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
04-02 22:55:53.304: E/AndroidRuntime(23942): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
04-02 22:55:53.304: E/AndroidRuntime(23942): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-02 22:55:53.304: E/AndroidRuntime(23942): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
04-02 22:55:53.304: E/AndroidRuntime(23942): at android.os.Handler.dispatchMessage(Handler.java:99)
04-02 22:55:53.304: E/AndroidRuntime(23942): at android.os.Looper.loop(Looper.java:130)
04-02 22:55:53.304: E/AndroidRuntime(23942): at android.app.ActivityThread.main(ActivityThread.java:3687)
04-02 22:55:53.304: E/AndroidRuntime(23942): at java.lang.reflect.Method.invokeNative(Native Method)
04-02 22:55:53.304: E/AndroidRuntime(23942): at java.lang.reflect.Method.invoke(Method.java:507)
04-02 22:55:53.304: E/AndroidRuntime(23942): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
04-02 22:55:53.304: E/AndroidRuntime(23942): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
04-02 22:55:53.304: E/AndroidRuntime(23942): at dalvik.system.NativeStart.main(Native Method)
04-02 22:55:53.304: E/AndroidRuntime(23942): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
04-02 22:55:53.304: E/AndroidRuntime(23942): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
04-02 22:55:53.304: E/AndroidRuntime(23942): at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
04-02 22:55:53.304: E/AndroidRuntime(23942): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-02 22:55:53.304: E/AndroidRuntime(23942): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-02 22:55:53.304: E/AndroidRuntime(23942): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:209)
04-02 22:55:53.304: E/AndroidRuntime(23942): at android.app.Activity.setContentView(Activity.java:1657)
04-02 22:55:53.304: E/AndroidRuntime(23942): at com.example.theapp.MainActivity.onCreate(MainActivity.java:11)
04-02 22:55:53.304: E/AndroidRuntime(23942): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-02 22:55:53.304: E/AndroidRuntime(23942): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
04-02 22:55:53.304: E/AndroidRuntime(23942): ... 11 more
04-02 22:55:53.304: E/AndroidRuntime(23942): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.example.theapp-2.apk]
04-02 22:55:53.304: E/AndroidRuntime(23942): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
04-02 22:55:53.304: E/AndroidRuntime(23942): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
04-02 22:55:53.304: E/AndroidRuntime(23942): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
04-02 22:55:53.304: E/AndroidRuntime(23942): at android.view.LayoutInflater.createView(LayoutInflater.java:471)
04-02 22:55:53.304: E/AndroidRuntime(23942): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)
04-02 22:55:53.304: E/AndroidRuntime(23942): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
04-02 22:55:53.304: E/AndroidRuntime(23942): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
04-02 22:55:53.304: E/AndroidRuntime(23942): ... 19 more
Any help would be appreciated. Thank you in advance.
package com.example.theapp;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
and in manifest add one more meta tag below previous one.
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="Api key" />
As far as I remember, You should include android-support-v4.jar file from Android SDK folder "sdk/extras/android/support/v4/android-support-v4.jar". If You dont have that file, in Your SDK Manager install Android Support Library, which is found under Extras.
Please check the following steps:
In android manifest you have the NETWORK STATE permission like this
< uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
In android manifest make sure you have the following code as well-
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value=" YOUR KEY HERE" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
Lastly if you are testing your application on android API 5.x then make sure you modify your map code like this-
Instead of this
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
write this
map = getMapFragment().getMap();
and add a small method like this
private MapFragment getMapFragment() {
FragmentManager fm = null;
Log.d("", "sdk: " + Build.VERSION.SDK_INT);
Log.d("", "release: " + Build.VERSION.RELEASE);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
Log.d("", "using getFragmentManager");
fm = getFragmentManager();
} else {
Log.d("", "using getChildFragmentManager");
fm = getChildFragmentManager();
}
return (MapFragment) fm.findFragmentById(R.id.map);
}
And make sure for step 3 your min sdk version in your manifest file is 17 like this
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="21" />
My app will start if I don't take away the title bar but when I do it crashes as soon as it starts.
This is the code I have so far.
?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.v1.solitare"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name">
<activity
android:name="com.v1.solitare.MainActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Please help in any way possible. I just picked up Android coding with Eclipse today and I'm very new at it.
Edit: I think I found the LogCat Errors for it:
04-02 22:06:28.986: E/AndroidRuntime(28352): FATAL EXCEPTION: main
04-02 22:06:28.986: E/AndroidRuntime(28352): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.v1.solitare/com.v1.solitare.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
04-02 22:06:28.986: E/AndroidRuntime(28352): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2305)
04-02 22:06:28.986: E/AndroidRuntime(28352): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2359)
04-02 22:06:28.986: E/AndroidRuntime(28352): at android.app.ActivityThread.access$700(ActivityThread.java:165)
04-02 22:06:28.986: E/AndroidRuntime(28352): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1326)
04-02 22:06:28.986: E/AndroidRuntime(28352): at android.os.Handler.dispatchMessage(Handler.java:99)
04-02 22:06:28.986: E/AndroidRuntime(28352): at android.os.Looper.loop(Looper.java:137)
04-02 22:06:28.986: E/AndroidRuntime(28352): at android.app.ActivityThread.main(ActivityThread.java:5455)
04-02 22:06:28.986: E/AndroidRuntime(28352): at java.lang.reflect.Method.invokeNative(Native Method)
04-02 22:06:28.986: E/AndroidRuntime(28352): at java.lang.reflect.Method.invoke(Method.java:525)
04-02 22:06:28.986: E/AndroidRuntime(28352): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
04-02 22:06:28.986: E/AndroidRuntime(28352): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
04-02 22:06:28.986: E/AndroidRuntime(28352): at dalvik.system.NativeStart.main(Native Method)
04-02 22:06:28.986: E/AndroidRuntime(28352): Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
04-02 22:06:28.986: E/AndroidRuntime(28352): at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:111)
04-02 22:06:28.986: E/AndroidRuntime(28352): at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58)
04-02 22:06:28.986: E/AndroidRuntime(28352): at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
04-02 22:06:28.986: E/AndroidRuntime(28352): at com.v1.solitare.MainActivity.onCreate(MainActivity.java:18)
04-02 22:06:28.986: E/AndroidRuntime(28352): at android.app.Activity.performCreate(Activity.java:5372)
04-02 22:06:28.986: E/AndroidRuntime(28352): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
04-02 22:06:28.986: E/AndroidRuntime(28352): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267)
04-02 22:06:28.986: E/AndroidRuntime(28352): ... 11 more
ActionBarActivity assumes you are using an ActionBar, while Theme.NoTitleBar themes remove the ActionBar (as that is part of the title bar on newer devices and ActionBarActivity assumes you are using a Theme.AppCompat theme which controls styling for the ActionBar).
Change your activity to extend FragmentActivity if you are okay with not having an Action Bar, although as per the Android design docs is a critical component for making your app feel like an Android app (although some would say that games are granted more leeway).
I just download the ADT Bundle, update the eclipse plugin, update the extras and tools folder from the sdk, import google play services and google maps sample from the sdk I have this error
04-02 13:49:26.031: E/AndroidRuntime(11469): FATAL EXCEPTION: main
04-02 13:49:26.031: E/AndroidRuntime(11469): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mapdemo/com.example.mapdemo.BasicMapDemoActivity}: android.view.InflateException: Binary XML file line #18: Error inflating class fragment
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122)
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.app.ActivityThread.access$600(ActivityThread.java:140)
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.os.Handler.dispatchMessage(Handler.java:99)
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.os.Looper.loop(Looper.java:137)
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.app.ActivityThread.main(ActivityThread.java:4895)
04-02 13:49:26.031: E/AndroidRuntime(11469): at java.lang.reflect.Method.invokeNative(Native Method)
04-02 13:49:26.031: E/AndroidRuntime(11469): at java.lang.reflect.Method.invoke(Method.java:511)
04-02 13:49:26.031: E/AndroidRuntime(11469): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
04-02 13:49:26.031: E/AndroidRuntime(11469): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
04-02 13:49:26.031: E/AndroidRuntime(11469): at dalvik.system.NativeStart.main(Native Method)
04-02 13:49:26.031: E/AndroidRuntime(11469): Caused by: android.view.InflateException: Binary XML file line #18: Error inflating class fragment
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
04-02 13:49:26.031: E/AndroidRuntime(11469): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:306)
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.app.Activity.setContentView(Activity.java:1912)
04-02 13:49:26.031: E/AndroidRuntime(11469): at com.example.mapdemo.BasicMapDemoActivity.onCreate(BasicMapDemoActivity.java:42)
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.app.Activity.performCreate(Activity.java:5163)
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061)
04-02 13:49:26.031: E/AndroidRuntime(11469): ... 11 more
04-02 13:49:26.031: E/AndroidRuntime(11469): Caused by: android.content.res.Resources$NotFoundException: File res/drawable/maps_popup_pointer_button.xml from drawable resource ID #0x7f0201b7
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.content.res.Resources.loadDrawable(Resources.java:1951)
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.content.res.Resources.getDrawable(Resources.java:672)
04-02 13:49:26.031: E/AndroidRuntime(11469): at maps.e.bm.a(Unknown Source)
04-02 13:49:26.031: E/AndroidRuntime(11469): at maps.e.al.a(Unknown Source)
04-02 13:49:26.031: E/AndroidRuntime(11469): at maps.e.bh.a(Unknown Source)
04-02 13:49:26.031: E/AndroidRuntime(11469): at maps.e.bg.a(Unknown Source)
04-02 13:49:26.031: E/AndroidRuntime(11469): at etu.onTransact(SourceFile:107)
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.os.Binder.transact(Binder.java:326)
04-02 13:49:26.031: E/AndroidRuntime(11469): at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onCreateView(Unknown Source)
04-02 13:49:26.031: E/AndroidRuntime(11469): at com.google.android.gms.maps.SupportMapFragment$a.onCreateView(Unknown Source)
04-02 13:49:26.031: E/AndroidRuntime(11469): at com.google.android.gms.dynamic.a$4.b(Unknown Source)
04-02 13:49:26.031: E/AndroidRuntime(11469): at com.google.android.gms.dynamic.a.a(Unknown Source)
04-02 13:49:26.031: E/AndroidRuntime(11469): at com.google.android.gms.dynamic.a.onCreateView(Unknown Source)
04-02 13:49:26.031: E/AndroidRuntime(11469): at com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:900)
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1082)
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1184)
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:291)
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
04-02 13:49:26.031: E/AndroidRuntime(11469): ... 20 more
04-02 13:49:26.031: E/AndroidRuntime(11469): Caused by: android.content.res.Resources$NotFoundException: File res/drawable/maps_popup_pointer_button.xml from xml type drawable resource ID #0x7f0201b7
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2178)
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.content.res.Resources.loadDrawable(Resources.java:1946)
04-02 13:49:26.031: E/AndroidRuntime(11469): ... 39 more
04-02 13:49:26.031: E/AndroidRuntime(11469): Caused by: java.io.FileNotFoundException: res/drawable/maps_popup_pointer_button.xml
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.content.res.AssetManager.openXmlAssetNative(Native Method)
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:487)
04-02 13:49:26.031: E/AndroidRuntime(11469): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2160)
04-02 13:49:26.031: E/AndroidRuntime(11469): ... 40 more
04-02 13:49:26.062: E/android.os.Debug(307): !#Dumpstate > dumpstate -k -t -z -d -o /data/log/dumpstate_app_error
Some folder from the proyect and lib configuration
https://www.dropbox.com/sh/12sksspx5a42bnq/lNUKGtsUgI#/
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mapdemo"
android:versionCode="6"
android:versionName="2.7.0">
<!-- Copied from Google Maps Library/AndroidManifest.xml. -->
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="17"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- External storage for caching. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- My Location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!-- Maps API needs OpenGL ES 2.0. -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<!-- End of copy. -->
<application
android:icon="#drawable/ic_launcher"
android:label="#string/demo_title"
android:hardwareAccelerated="true">
<!-- ** You need to replace the key below with your own key. **
The example key below will not be accepted because it is not linked to the
certificate which you will use to sign this application.
See: https://developers.google.com/maps/documentation/android/start
for instructions on how to get your own key. -->
<meta-data android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCvGBr5in13NK2********Ttnxj3mrXQy4"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".LegalInfoActivity"
android:label="#string/legal_info"/>
<activity
android:name=".BasicMapDemoActivity"
android:label="#string/basic_map_demo_label"/>
<activity
android:name=".CameraDemoActivity"
android:label="#string/camera_demo_label"/>
<activity
android:name=".CircleDemoActivity"
android:label="#string/circle_demo_label"/>
<activity
android:name=".EventsDemoActivity"
android:label="#string/events_demo_label"/>
<activity
android:name=".GroundOverlayDemoActivity"
android:label="#string/ground_overlay_demo_label"/>
<activity
android:name=".LayersDemoActivity"
android:label="#string/layers_demo_label"/>
<activity
android:name=".LocationSourceDemoActivity"
android:label="#string/location_source_demo_label"/>
<activity
android:name=".MapInPagerDemoActivity"
android:label="#string/map_in_pager_demo_label"/>
<activity
android:name=".MarkerDemoActivity"
android:label="#string/marker_demo_label"/>
<activity
android:name=".MultiMapDemoActivity"
android:label="#string/multi_map_demo_label"/>
<activity
android:name=".MyLocationDemoActivity"
android:label="#string/my_location_demo_label"/>
<activity
android:name=".OptionsDemoActivity"
android:label="#string/options_demo_label"/>
<activity
android:name=".PolygonDemoActivity"
android:label="#string/polygon_demo_label"/>
<activity
android:name=".PolylineDemoActivity"
android:label="#string/polyline_demo_label"/>
<activity
android:name=".ProgrammaticDemoActivity"
android:label="#string/programmatic_demo_label"/>
<activity
android:name=".RawMapViewDemoActivity"
android:label="#string/raw_map_view_demo_label"/>
<activity
android:name=".RetainMapDemoActivity"
android:label="#string/retain_map_demo_label"/>
<activity
android:name=".SaveStateDemoActivity"
android:label="#string/save_state_demo_label"/>
<activity
android:name=".SnapshotDemoActivity"
android:label="#string/snapshot_demo_label"/>
<activity
android:name=".TileCoordinateDemoActivity"
android:label="#string/tile_coordinate_demo_label"/>
<activity
android:name=".TileOverlayDemoActivity"
android:label="#string/tile_overlay_demo_label"/>
<activity
android:name=".UiSettingsDemoActivity"
android:label="#string/ui_settings_demo_label"/>
<activity
android:name=".VisibleRegionDemoActivity"
android:label="#string/visible_region_demo_label"/>
</application>
</manifest>
the layout
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2012 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- This can go anywhere in your layout (see other demos for some examples). -->
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
If a create the map via Java like this
mapaVirtual = SupportMapFragment.newInstance();
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.add(R.id.map, mapaVirtual, "TAG");
ft.commit();
mapaVirtual = new SupportMapFragment()
{
#Override
public void onActivityCreated(Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
GoogleMap map = mapaVirtual.getMap();
if (map != null)
{
mapa = mapaVirtual.getMap();
mapa.setMyLocationEnabled(true);
mapa.setOnInfoWindowClickListener(new OnInfoWindowClickListener()
{
#Override
public void onInfoWindowClick(Marker marker)
{
}
});
mapa.setOnMarkerClickListener(new OnMarkerClickListener()
{
public boolean onMarkerClick(Marker marker)
{
return false;
}
});
}
}
};
Same error
UPDATE
Some testing
Samsung G3 - Mini with 4.1.2 Google Play services client version: 3159100 > Works
Samsung Galaxy Tab 2 7.0 with 4.1.1 Google Play services cliente version: 3159100 > Not works
I want to show current location in map using Google Map v2. I create sha key and generate API key and also integrate with androidmanifest.xml. I download example of following link:
http://wptrafficanalyzer.in/blog/showing-current-location-in-google-maps-using-api-v2-with-supportmapfragment/
I also give internet permission and other but in my log-cat following error display.
11-20 11:09:59.190: E/dalvikvm(719): Could not find class 'com.google.android.gms.maps.model.LatLng', referenced from method in.wptrafficanalyzer.locationingooglemapv2.MainActivity.onLocationChanged
11-20 11:09:59.190: W/dalvikvm(719): VFY: unable to resolve new-instance 460 (Lcom/google/android/gms/maps/model/LatLng;) in Lin/wptrafficanalyzer/locationingooglemapv2/MainActivity;
11-20 11:09:59.190: D/dalvikvm(719): VFY: replacing opcode 0x22 at 0x0010
11-20 11:09:59.220: D/dalvikvm(719): DexOpt: unable to opt direct call 0x0cdc at 0x12 in Lin/wptrafficanalyzer/locationingooglemapv2/MainActivity;.onLocationChanged
11-20 11:09:59.482: D/AndroidRuntime(719): Shutting down VM
11-20 11:09:59.482: W/dalvikvm(719): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
11-20 11:09:59.501: E/AndroidRuntime(719): FATAL EXCEPTION: main
11-20 11:09:59.501: E/AndroidRuntime(719): java.lang.RuntimeException: Unable to start activity ComponentInfo{in.wptrafficanalyzer.locationingooglemapv2/in.wptrafficanalyzer.locationingooglemapv2.MainActivity}: android.view.InflateException: Binary XML file line #13: Error inflating class fragment
11-20 11:09:59.501: E/AndroidRuntime(719): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.app.ActivityThread.access$600(ActivityThread.java:130)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.os.Handler.dispatchMessage(Handler.java:99)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.os.Looper.loop(Looper.java:137)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.app.ActivityThread.main(ActivityThread.java:4745)
11-20 11:09:59.501: E/AndroidRuntime(719): at java.lang.reflect.Method.invokeNative(Native Method)
11-20 11:09:59.501: E/AndroidRuntime(719): at java.lang.reflect.Method.invoke(Method.java:511)
11-20 11:09:59.501: E/AndroidRuntime(719): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-20 11:09:59.501: E/AndroidRuntime(719): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-20 11:09:59.501: E/AndroidRuntime(719): at dalvik.system.NativeStart.main(Native Method)
11-20 11:09:59.501: E/AndroidRuntime(719): Caused by: android.view.InflateException: Binary XML file line #13: Error inflating class fragment
11-20 11:09:59.501: E/AndroidRuntime(719): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
11-20 11:09:59.501: E/AndroidRuntime(719): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.app.Activity.setContentView(Activity.java:1867)
11-20 11:09:59.501: E/AndroidRuntime(719): at in.wptrafficanalyzer.locationingooglemapv2.MainActivity.onCreate(MainActivity.java:27)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.app.Activity.performCreate(Activity.java:5008)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
11-20 11:09:59.501: E/AndroidRuntime(719): ... 11 more
11-20 11:09:59.501: E/AndroidRuntime(719): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.SupportMapFragment: make sure class name exists, is public, and has an empty constructor that is public
11-20 11:09:59.501: E/AndroidRuntime(719): at android.support.v4.app.Fragment.instantiate(Fragment.java:401)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.support.v4.app.Fragment.instantiate(Fragment.java:369)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
11-20 11:09:59.501: E/AndroidRuntime(719): ... 21 more
11-20 11:09:59.501: E/AndroidRuntime(719): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.SupportMapFragment
11-20 11:09:59.501: E/AndroidRuntime(719): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
11-20 11:09:59.501: E/AndroidRuntime(719): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
11-20 11:09:59.501: E/AndroidRuntime(719): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.support.v4.app.Fragment.instantiate(Fragment.java:391)
11-20 11:09:59.501: E/AndroidRuntime(719): ... 24 more
Now what i can do for displaying map?
Maps Activity
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
activity_main
<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 xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
</RelativeLayout>
Manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="YourPackageName"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="YourPackageName.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="YourPackageName.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="YourPackageName.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.gms.version"
android:value="4030500" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="YourKey" />
</application>`enter code here`
</manifest>
Open sdk manager and download google play service under extras, you will get two libraries google-play-services_lib.jar and google-play-services.jar. You can find these libraries under google play service in extras. You have to copy these two libraries and paste under lib folder in your app and also add these libraries under java Build path.
make sure by going to google api console go to services in go down you will find google map v2 eanble it...
To add a reference to a library project, follow these steps:
1. Make sure that both the project library and the application project that depends on it are in your workspace. If one of the projects is missing, import it into your workspace.
2. In the Package Explorer, right-click the dependent project and select Properties.
3.In the Properties window, select the "Android" properties group at left and locate the Library properties at right.
4.Click Add to open the Project Selection dialog.
5.From the list of available library projects, select a project and click OK.
6.When the dialog closes, click Apply in the Properties window.
7.Click OK to close the Properties window.
how to add reference Google play Library
Android Library Projects