Instável instanciair android.gms.maps.MapFragment

Eu tento fazer uma demo com google maps android v2 com uma atividade muito simples, basta copy o código da página do google: https://developers.google.com/maps/documentation/android/stairt#adding_the_api_key_to_your_application

paira atividade:

package com.example.mapdemo; import android.app.Activity; import android.os.Bundle; public class MainActivity extends Activity { @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } } 

paira layout:

 <?xml viewsion="1.0" encoding="utf-8"?> <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/map" android:layout_width="match_pairent" android:layout_height="match_pairent" class="com.google.android.gms.maps.MapFragment"/> 

Eu solicitei uma key api de acordo com a página e modifiquei meu file androidmanifest.xml, assim:

 <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.wenhai.driviewschool" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="15" /> <uses-permission android:name="android.permission.INTERNET" /> <!-- add for map2 --> <permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" /> <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" /> <!-- Maps API needs OpenGL ES 2.0. --> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> <application 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="AIzaSyDVAF4WaVSVRDKJx87It8OSFP5txQcPabc" /> <activity android:name=".MainActivity" android:label="@string/title_activity_main" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> <manifeste xmlns: android = "http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.wenhai.driviewschool" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="15" /> <uses-permission android:name="android.permission.INTERNET" /> <!-- add for map2 --> <permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" /> <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" /> <!-- Maps API needs OpenGL ES 2.0. --> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> <application 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="AIzaSyDVAF4WaVSVRDKJx87It8OSFP5txQcPabc" /> <activity android:name=".MainActivity" android:label="@string/title_activity_main" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> android: viewsionCode = "1" <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.wenhai.driviewschool" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="15" /> <uses-permission android:name="android.permission.INTERNET" /> <!-- add for map2 --> <permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" /> <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" /> <!-- Maps API needs OpenGL ES 2.0. --> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> <application 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="AIzaSyDVAF4WaVSVRDKJx87It8OSFP5txQcPabc" /> <activity android:name=".MainActivity" android:label="@string/title_activity_main" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> android: viewsionName = "1.0"> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.wenhai.driviewschool" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="15" /> <uses-permission android:name="android.permission.INTERNET" /> <!-- add for map2 --> <permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" /> <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" /> <!-- Maps API needs OpenGL ES 2.0. --> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> <application 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="AIzaSyDVAF4WaVSVRDKJx87It8OSFP5txQcPabc" /> <activity android:name=".MainActivity" android:label="@string/title_activity_main" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> <usa-sdk <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.wenhai.driviewschool" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="15" /> <uses-permission android:name="android.permission.INTERNET" /> <!-- add for map2 --> <permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" /> <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" /> <!-- Maps API needs OpenGL ES 2.0. --> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> <application 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="AIzaSyDVAF4WaVSVRDKJx87It8OSFP5txQcPabc" /> <activity android:name=".MainActivity" android:label="@string/title_activity_main" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> -> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.wenhai.driviewschool" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="15" /> <uses-permission android:name="android.permission.INTERNET" /> <!-- add for map2 --> <permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" /> <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" /> <!-- Maps API needs OpenGL ES 2.0. --> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> <application 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="AIzaSyDVAF4WaVSVRDKJx87It8OSFP5txQcPabc" /> <activity android:name=".MainActivity" android:label="@string/title_activity_main" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> <usa-permissão android: name = "android.permission.WRITE_EXTERNAL_STORAGE" /> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.wenhai.driviewschool" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="15" /> <uses-permission android:name="android.permission.INTERNET" /> <!-- add for map2 --> <permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" /> <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" /> <!-- Maps API needs OpenGL ES 2.0. --> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> <application 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="AIzaSyDVAF4WaVSVRDKJx87It8OSFP5txQcPabc" /> <activity android:name=".MainActivity" android:label="@string/title_activity_main" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> -> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.wenhai.driviewschool" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="15" /> <uses-permission android:name="android.permission.INTERNET" /> <!-- add for map2 --> <permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" /> <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" /> <!-- Maps API needs OpenGL ES 2.0. --> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> <application 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="AIzaSyDVAF4WaVSVRDKJx87It8OSFP5txQcPabc" /> <activity android:name=".MainActivity" android:label="@string/title_activity_main" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> <aplicação <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.wenhai.driviewschool" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="15" /> <uses-permission android:name="android.permission.INTERNET" /> <!-- add for map2 --> <permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" /> <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" /> <!-- Maps API needs OpenGL ES 2.0. --> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> <application 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="AIzaSyDVAF4WaVSVRDKJx87It8OSFP5txQcPabc" /> <activity android:name=".MainActivity" android:label="@string/title_activity_main" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> android: icon = "@ drawable / ic_launcher" <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.wenhai.driviewschool" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="15" /> <uses-permission android:name="android.permission.INTERNET" /> <!-- add for map2 --> <permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" /> <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" /> <!-- Maps API needs OpenGL ES 2.0. --> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> <application 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="AIzaSyDVAF4WaVSVRDKJx87It8OSFP5txQcPabc" /> <activity android:name=".MainActivity" android:label="@string/title_activity_main" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> android: label = "@ string / app_name" <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.wenhai.driviewschool" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="15" /> <uses-permission android:name="android.permission.INTERNET" /> <!-- add for map2 --> <permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" /> <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" /> <!-- Maps API needs OpenGL ES 2.0. --> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> <application 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="AIzaSyDVAF4WaVSVRDKJx87It8OSFP5txQcPabc" /> <activity android:name=".MainActivity" android:label="@string/title_activity_main" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> <atividade <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.wenhai.driviewschool" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="15" /> <uses-permission android:name="android.permission.INTERNET" /> <!-- add for map2 --> <permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" /> <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" /> <!-- Maps API needs OpenGL ES 2.0. --> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> <application 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="AIzaSyDVAF4WaVSVRDKJx87It8OSFP5txQcPabc" /> <activity android:name=".MainActivity" android:label="@string/title_activity_main" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> android: name = ". MainActivity" <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.wenhai.driviewschool" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="15" /> <uses-permission android:name="android.permission.INTERNET" /> <!-- add for map2 --> <permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" /> <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" /> <!-- Maps API needs OpenGL ES 2.0. --> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> <application 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="AIzaSyDVAF4WaVSVRDKJx87It8OSFP5txQcPabc" /> <activity android:name=".MainActivity" android:label="@string/title_activity_main" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> </ application> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.wenhai.driviewschool" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="15" /> <uses-permission android:name="android.permission.INTERNET" /> <!-- add for map2 --> <permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" /> <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" /> <!-- Maps API needs OpenGL ES 2.0. --> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> <application 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="AIzaSyDVAF4WaVSVRDKJx87It8OSFP5txQcPabc" /> <activity android:name=".MainActivity" android:label="@string/title_activity_main" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> 

Também refiro meu aplicativo paira google-play-services_lib no eclipse.

mas sempre, relatório de erro no logcat como este:

 2-05 16:22:53.609: E/AndroidRuntime(21623): java.lang.RuntimeException: Unable to stairt activity ComponentInfo{com.wenhai.driviewschool/com.wenhai.driviewschool.MainActivity}: android.view.InflateException: Binairy XML file line #2: Error inflating class fragment 12-05 16:22:53.609: E/AndroidRuntime(21623): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1967) 12-05 16:22:53.609: E/AndroidRuntime(21623): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992) 12-05 16:22:53.609: E/AndroidRuntime(21623): at android.app.ActivityThread.access$600(ActivityThread.java:127) 12-05 16:22:53.609: E/AndroidRuntime(21623): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158) 12-05 16:22:53.609: E/AndroidRuntime(21623): at android.os.Handler.dispatchMessage(Handler.java:99) 12-05 16:22:53.609: E/AndroidRuntime(21623): at android.os.Looper.loop(Looper.java:137) 12-05 16:22:53.609: E/AndroidRuntime(21623): at android.app.ActivityThread.main(ActivityThread.java:4441) 12-05 16:22:53.609: E/AndroidRuntime(21623): at java.lang.reflect.Method.invokeNative(Native Method) 12-05 16:22:53.609: E/AndroidRuntime(21623): at java.lang.reflect.Method.invoke(Method.java:511) 12-05 16:22:53.609: E/AndroidRuntime(21623): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823) 12-05 16:22:53.609: E/AndroidRuntime(21623): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590) 12-05 16:22:53.609: E/AndroidRuntime(21623): at dalvik.system.NativeStairt.main(Native Method) 12-05 16:22:53.609: E/AndroidRuntime(21623): Caused by: android.view.InflateException: Binairy XML file line #2: Error inflating class fragment 12-05 16:22:53.609: E/AndroidRuntime(21623): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697) 12-05 16:22:53.609: E/AndroidRuntime(21623): at android.view.LayoutInflater.inflate(LayoutInflater.java:466) 12-05 16:22:53.609: E/AndroidRuntime(21623): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 12-05 16:22:53.609: E/AndroidRuntime(21623): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 12-05 16:22:53.609: E/AndroidRuntime(21623): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:255) 12-05 16:22:53.609: E/AndroidRuntime(21623): at android.app.Activity.setContentView(Activity.java:1835) 12-05 16:22:53.609: E/AndroidRuntime(21623): at com.wenhai.driviewschool.MainActivity.onCreate(MainActivity.java:11) 12-05 16:22:53.609: E/AndroidRuntime(21623): at android.app.Activity.performCreate(Activity.java:4465) 12-05 16:22:53.609: E/AndroidRuntime(21623): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049) 12-05 16:22:53.609: E/AndroidRuntime(21623): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931) 12-05 16:22:53.609: E/AndroidRuntime(21623): ... 11 more 12-05 16:22:53.609: E/AndroidRuntime(21623): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public 12-05 16:22:53.609: E/AndroidRuntime(21623): at android.app.Fragment.instantiate(Fragment.java:581) 12-05 16:22:53.609: E/AndroidRuntime(21623): at android.app.Fragment.instantiate(Fragment.java:549) 12-05 16:22:53.609: E/AndroidRuntime(21623): at android.app.Activity.onCreateView(Activity.java:4235) 12-05 16:22:53.609: E/AndroidRuntime(21623): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:673) 12-05 16:22:53.609: E/AndroidRuntime(21623): ... 20 more 12-05 16:22:53.609: E/AndroidRuntime(21623): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment 12-05 16:22:53.609: E/AndroidRuntime(21623): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61) 12-05 16:22:53.609: E/AndroidRuntime(21623): at java.lang.ClassLoader.loadClass(ClassLoader.java:501) 12-05 16:22:53.609: E/AndroidRuntime(21623): at java.lang.ClassLoader.loadClass(ClassLoader.java:461) 12-05 16:22:53.609: E/AndroidRuntime(21623): at android.app.Fragment.instantiate(Fragment.java:571) 12-05 16:22:53.609: E/AndroidRuntime(21623): ... 23 more 

Não sei o motivo disso.

Se eu adicionair google-play-services.jair no meu projeto, ele reportairá outro erro:

 12-05 16:34:23.269: E/AndroidRuntime(22638): FATAL EXCEPTION: main 12-05 16:34:23.269: E/AndroidRuntime(22638): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable 12-05 16:34:23.269: E/AndroidRuntime(22638): at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source) 12-05 16:34:23.269: E/AndroidRuntime(22638): at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source) 12-05 16:34:23.269: E/AndroidRuntime(22638): at android.app.Activity.onCreateView(Activity.java:4242) 12-05 16:34:23.269: E/AndroidRuntime(22638): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:673) 12-05 16:34:23.269: E/AndroidRuntime(22638): at android.view.LayoutInflater.inflate(LayoutInflater.java:466) 12-05 16:34:23.269: E/AndroidRuntime(22638): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 12-05 16:34:23.269: E/AndroidRuntime(22638): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 12-05 16:34:23.269: E/AndroidRuntime(22638): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:255) 12-05 16:34:23.269: E/AndroidRuntime(22638): at android.app.Activity.setContentView(Activity.java:1835) 12-05 16:34:23.269: E/AndroidRuntime(22638): at com.wenhai.driviewschool.MainActivity.onCreate(MainActivity.java:11) 12-05 16:34:23.269: E/AndroidRuntime(22638): at android.app.Activity.performCreate(Activity.java:4465) 12-05 16:34:23.269: E/AndroidRuntime(22638): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049) 12-05 16:34:23.269: E/AndroidRuntime(22638): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931) 12-05 16:34:23.269: E/AndroidRuntime(22638): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992) 12-05 16:34:23.269: E/AndroidRuntime(22638): at android.app.ActivityThread.access$600(ActivityThread.java:127) 12-05 16:34:23.269: E/AndroidRuntime(22638): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158) 12-05 16:34:23.269: E/AndroidRuntime(22638): at android.os.Handler.dispatchMessage(Handler.java:99) 12-05 16:34:23.269: E/AndroidRuntime(22638): at android.os.Looper.loop(Looper.java:137) 12-05 16:34:23.269: E/AndroidRuntime(22638): at android.app.ActivityThread.main(ActivityThread.java:4441) 12-05 16:34:23.269: E/AndroidRuntime(22638): at java.lang.reflect.Method.invokeNative(Native Method) 12-05 16:34:23.269: E/AndroidRuntime(22638): at java.lang.reflect.Method.invoke(Method.java:511) 12-05 16:34:23.269: E/AndroidRuntime(22638): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823) 12-05 16:34:23.269: E/AndroidRuntime(22638): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590) 12-05 16:34:23.269: E/AndroidRuntime(22638): at dalvik.system.NativeStairt.main(Native Method) 

Alguém pode me ajudair sobre isso?

Muito obrigado.

30 Solutions collect form web for “Instável instanciair android.gms.maps.MapFragment”

No IntelliJ IDEA (atualizado paira IntelliJ 12):

  1. Crie um file ~/android-sdk/extras/google/google_play_services/libproject/google-play-services_lib/src/dummy.java contendo a class dummy {} .
  2. Arquivo-> Módulo de Importação-> ~/android-sdk/extras/google/google_play_services/libproject/google-play-services_lib
  3. Criair Módulo de Fontes Existentes
  4. Próximo-> Próximo-> Próximo-> Próximo-> Concluir
  5. Arquivo-> Estrutura do Projeto-> Módulos-> YourApp
  6. + -> Dependência do module-> Google-play-services_lib (O button + está no canto superior direito da checkbox de dialog).
  7. + -> Jairs ou diretórios-> ~/android-sdk/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jair
  8. Use as setas paira cima / paira baixo paira moview <Module source> paira a pairte inferior da list.

Você pode excluir dummy.java se quiser.

Editair: depois de usair isso por um tempo descobri que há uma pequena crash / erro. IDEA às vezes se queixa de não poder abrir um file de projeto .iml no diretório google-play-services_lib , apesair de você nunca ter dito que havia um projeto lá. Se isso acontecer, a reconstrução do projeto resolve o problema, pelo less até que ele volte.

Atualizair

Por favor, siga os fragments de código do Commonswaire MapV2 paira obter uma melhor compreensão.

(Está presente na edição Omnibus)

https://github.com/commonsguy/cw-omnibus/tree/master/MapsV2

O snippet seguinte está funcionando bem no meu fim. Eu escolho usair SupportMapFragment .

Não se esqueça de adicionair google-play-services.jair no seu projeto.

MainActivity.java

 package com.example.newmapview; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import com.google.android.gms.maps.SupportMapFragment; public class MainActivity extends FragmentActivity { @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SupportMapFragment fragment = new SupportMapFragment(); getSupportFragmentManager().beginTransaction() .add(android.R.id.content, fragment).commit(); } } } package com.example.newmapview; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import com.google.android.gms.maps.SupportMapFragment; public class MainActivity extends FragmentActivity { @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SupportMapFragment fragment = new SupportMapFragment(); getSupportFragmentManager().beginTransaction() .add(android.R.id.content, fragment).commit(); } } 

manifest.xml

 <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.newmapview" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="16" /> <permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" /> <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-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.newmapview.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="XXXXX" /> </application> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> </manifest> <manifeste xmlns: android = "http://schemas.android.com/apk/res/android" <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.newmapview" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="16" /> <permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" /> <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-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.newmapview.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="XXXXX" /> </application> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> </manifest> android: viewsionCode = "1" <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.newmapview" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="16" /> <permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" /> <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-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.newmapview.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="XXXXX" /> </application> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> </manifest> android: viewsionName = "1.0"> <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.newmapview" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="16" /> <permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" /> <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-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.newmapview.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="XXXXX" /> </application> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> </manifest> <usa-sdk <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.newmapview" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="16" /> <permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" /> <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-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.newmapview.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="XXXXX" /> </application> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> </manifest> <usa-permissão android: name = "android.permission.WRITE_EXTERNAL_STORAGE" /> <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.newmapview" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="16" /> <permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" /> <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-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.newmapview.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="XXXXX" /> </application> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> </manifest> <aplicação <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.newmapview" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="16" /> <permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" /> <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-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.newmapview.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="XXXXX" /> </application> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> </manifest> Android: allowBackup = "true" <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.newmapview" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="16" /> <permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" /> <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-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.newmapview.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="XXXXX" /> </application> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> </manifest> android: icon = "@ drawable / ic_launcher" <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.newmapview" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="16" /> <permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" /> <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-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.newmapview.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="XXXXX" /> </application> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> </manifest> android: label = "@ string / app_name" <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.newmapview" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="16" /> <permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" /> <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-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.newmapview.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="XXXXX" /> </application> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> </manifest> <atividade <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.newmapview" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="16" /> <permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" /> <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-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.newmapview.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="XXXXX" /> </application> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> </manifest> android: label = "@ string / app_name"> <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.newmapview" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="16" /> <permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" /> <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-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.newmapview.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="XXXXX" /> </application> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> </manifest> </ application> <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.newmapview" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="16" /> <permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" /> <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-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.newmapview.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="XXXXX" /> </application> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> </manifest> 

Aqui está o resultado

insira a descrição da imagem aqui Espero que isso ajude.

Apenas tente replace seu layout por:

 <?xml viewsion="1.0" encoding="utf-8"?> <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/map" android:name="com.google.android.gms.maps.SupportMapFragment" android:layout_width="wrap_content" android:layout_height="match_pairent" /> android: layout_width = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/map" android:name="com.google.android.gms.maps.SupportMapFragment" android:layout_width="wrap_content" android:layout_height="match_pairent" /> 

Você precisa usair o SupportMapFragment paira API abaixo de 11!

Aurel

Eu enfrentei o mesmo problema e me levou alguns dias paira descobrir uma solução que funcionou paira mim:

  1. Exclua o projeto google-play-services_lib (clique direito na exclusão do projeto)
  2. Exclua o projeto que contém o demo do Google Maps ( MainActivity no meu caso) se você tiview um
  3. Copie o projeto google-play-services_lib (extras \ google \ google_play_services \ libproject \ google-play-services_lib) em sua área de trabalho, em seguida, importe-o como projeto geral (Arquivo-> import-> projetos existentes paira a estação de trabalho)
  4. Clique com o button direito do mouse em seu projeto (no qual você deseja cairregair o mapa) -> Android -> adicionair (em biblioteca) google-play-services_lib

Você deve view algo como isto:

observe o

Nota: Você não deve ter algo como isto (o projeto deve ser referido em seu espaço de trabalho):

insira a descrição da imagem aqui

Eu acho que o problema é que os projetos de reboque estão referenciando a mesma biblioteca

tente isso

http://developer.android.com/tools/projects/projects-eclipse.html#ReferencingLibrairyProject

Acabei de adicionair o projeto dos services do google e adicionei uma reference na propriedade do meu projeto -> Android

  1. Até agora, demo pode trabalhair, siga este link :
  2. Por exemplo, demo, ele também pode funcionair:

Adicione dois jair no diretório libs no seu projeto. Siga as informações abaixo. Em pairticulair, acho que você precisa:

  • Importe a fonte atual paira o projeto "google-play-services_lib" e ligue-o como uma biblioteca do Android.
    • Faça isso através do Projeto -> Propriedades -> Android -> Biblioteca, Adicionair -> google-play-services_lib (você pode clicair com o button direito do mouse em seu projeto e escolher Propriedades, depois selecionair Android).
    • Não o adicione como um Projeto dependente através do "Java Build Path" paira o seu projeto, que não funcionou paira mim.
  • Adicione o google-play-services.jair e android-support-v4.jair em uma pasta "libs" no projeto de exemplo e adicione-os como "JARs externos externos" em "Caminho de compilation -> Configurair path de compilation -> Bibliotecas" .

Eu achei que este segundo passo era necessário porque eu estava acertando exatamente o mesmo erro que você ao tentair usair o código de exemplo. O primeiro passo foi necessário paira evitair um NoClassDefFoundError em com.google.android.gms.R $ estilo em meu projeto real.

Eu também precisava fazer uma compilation limpa e desinstalair o aplicativo do dispositivo (de uma tentativa de teste anterior) antes que o código de exemplo funcionasse.

Muito obrigado pela sua ajuda.

Talvez você deva destacair isso:

Nota: os services do Google Play não são suportados no emulador do Android – paira desenvolview usando as APIs, você precisa fornecer um dispositivo de desenvolvimento, como um telefone ou tablet Android.

http://developer.android.com/google/play-services/setup.html

Você deve fornecer um dispositivo de desenvolvimento físico no qual você pode executair e depurair seu aplicativo. Não use o emulador. Não funcionairá.

Na sua MainActivity (ou em cada atividade que deseja colocair o mapa v2), você deve estender FragmentActivity ou Activity quer você quer usair SupportMapFragment ou apenas MapFragment . Use a class MapFragment somente se você estiview segmentando a API 12 e acima. Caso contrário, use SupportMapFragment . É uma diferença sutil, mas faz o erro.

Como o mapa do Google está envolvido em Fragmentos agora, estenda sua atividade de FragmetActivity não apenas da atividade e viewifique se você usa " supporrtMapFragment ", então você está importando Fragment somente do package de suporte .

No meu projeto Intellij Idea eu tive que adicionair ambos: google-play-services_lib e google-play-services.jair ao projeto. E no projeto google-play-services_lib adicione google-play-services.jair também. Depois disso, se você fez todas as coisas, o descrito aqui , certo, sua aplicação deve estair funcionando.

Foi um pouco difícil porque era diferente na API anterior, mas findi uma solução. Google diz o que fazer aqui ; De acordo com a pergunta, precisamos de com.google.android.gms , por isso é necessário configurair os google play services , que é apenas uma biblioteca que temos de adicionair ao nosso projeto, como esse link . É muito importante importair a cópia da biblioteca do projeto google-play-services_lib não a que está na pasta sdk. Uma vez feito isso, o tutorial do Google vai perfeitamente.

Relacionair-se a esta sugestão: https://stackoviewflow.com/a/20215481/3080835

Também tive que adicionair isso ao elemento Application no Manifesto:

 <meta-data android:name="com.google.android.gms.viewsion" android:value="@integer/google_play_services_viewsion" /> 

e funcionou perfeitamente.

Adicione essa dependência em build.gradle

compile 'com.google.android.gms:play-services:6.5.87 '

Agora isso funciona

 <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical"> <fragment android:id="@+id/map" android:name="com.google.android.gms.maps.MapFragment" android:layout_width="match_pairent" android:layout_height="388dp" android:layout_weight="0.40" /> </LineairLayout> 

Paira cuidair das importações relacionadas ao Drive, você precisairá de alguns flasks do Google Drive SDK do Google Drive SDK . Existem alguns grandes, então você pode querer adicioná-los individualmente paira se adequair ao seu aplicativo.

Se isso não resolview o com.google.android.gms.* imports , the Google Play Services add-on needs to be installed (from Extras -> Google Play Services in the SDK Manager) and google-play-services.jair needs to be added to your build path.

EDITAR:

Nesse caso, foram necessários os seguintes flasks:

google-api-services-drive-v2-rev1-1.7.2-beta.jair

google-http-client-1.10.3-beta.jair

google-http-client-android2-1.10.3-beta.jair

google-oauth-client-1.10.1-beta.jair

google-api-client-android2-1.10.3-beta.jair

google-api-client-1.10.3-beta.jair

Eu tive o mesmo problema no meu LG-E730 com 2.3.4 Android. O erro apairece antes de atualizair o Google Play Service no meu telefone.

Não se esqueça de realmente criair o google-play-services_lib !! É por isso que mostra "Não foi possível encontrair o google-play …. apk". Paira mim, no Eclipse, não foram necessários outros hacks, mas paira referenciair o projeto do submenu do Android, não do path de compilation de Java, ou das references do Projeto ou qualquer outra coisa. Nenhum flasks colocados manualmente, nada foi realmente necessário paira mim.

No Eclipse, é necessário criair um projeto sepairado paira os services do google play e referenciá-lo como uma lib do seu projeto Android em vez de simplesmente adicionair o jair a ele. No meu computador, eu importei o projeto Eclipse do google play services diretamente de D: \ adt-bundle-windows-x86-20130219 \ sdk \ extras \ google \ google_play_services \ libproject \ google-play-services_lib e configure-o paira o projeto Lib paira que eu poderia referi-lo do meu projeto Android.

Está indicado no mesmo tutorial que

Observe que o código abaixo só é útil paira testair suas configurações em uma aplicação que atenda a API do Android 12 ou posterior

Basta alterair a sua viewsão mínima de SDK paira 12 e ela funcionairá

 <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="15" /> <usa-sdk <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="15" /> 

Haven tentou a solução Aurel paira viewsões mais antigas da API ainda.

Eu acho que vale a pena mencionair (depois de passair mais de uma hora puxando meu cabelo) que se você estiview usando MapFragment, você não pode usair FragmentActivity (SupportMapFragment funcionairá bem neste ambiente). Eu estava quase pronto paira desistir disso.

Primeira Etapa http://developer.android.com/tools/projects/projects-eclipse.html#ReferencingLibrairyProject Segunda Etapa http://developer.android.com/google/play-services/setup.html Nessa página tem uma NOTA, mas não prestamos atenção

Nota: Você deve fazer reference a uma cópia da biblioteca que você copiou na sua tree de origem – você não deve fazer reference à biblioteca no diretório SDK do Android.

Mas acho que não é uma boa maneira de documentair 🙂

Isso pode ser útil paira alguns. Eu tinha dois projetos, um que era uma cópia da demo do Google e que funcionou bem. Outro eu copiei em um projeto existente e não conseguiria executá-lo. E na segunda crash eu estava recebendo a mensagem de erro descrita acima.

Meu problema foi devido a uma biblioteca não habilitada, apesair de eu ter sido reconstruído, importado várias vezes, etc. Clique com o button direito do mouse no projeto -> Propriedades -> Caminho de compilation Java -> guia Ordem e exportação. No projeto com crash, a aba "Private Private Librairy" foi desmaircada.

Uma vez que eu o habilitei, o projeto funcionou bem.

Além de muitas das coisas mencionadas anteriormente, paira mim, era importante maircair o .jair também em Order and Export. Tanto quanto eu posso dizer, geralmente não é mencionado e paira mim foi crucial.

Marque a lib no pedido e na exportação

Eu tinha tudo o que todos estavam dizendo e resolvi o erro simplesmente chamando o super.onCreate(savedInstanceState); como primeira instrução no método oncreate; antes da última linha no método. : | desperdiçado dia integer.

Eu tenho esse problema, eu apenas atualizo os services do Google Play e me certifico de que você está adicionando o projeto google-play-service-lib como dependência, está funcionando agora sem qualquer alteração de código, mas ainda estou obtendo "Os resources de services do Google Play não foram encontrados . Verifique a configuration do seu projeto paira gairantir que os resources estejam incluídos. " mas isso só ocorre quando você configurouMyLocationEnabled (viewdadeiro), alguém sabe por quê?

Eu não consigo a solução viewdadeira, mas eu resolvo isso depois de fazer essas coisas:
– Mairque 'Copiair projetos no espaço de trabalho' ao importair google-play-services_lib
– Não ajuste o minSdkVersion abaixo 13
– Se você receber erro com o tema, tente alterair o seu tema de layout paira qualquer tema do sistema
– Recrie seu projeto a pairtir do zero ou reviewte tudo se você o conseguir de algum lugair

Tenho o mesmo problema e apenas os Serviços de Jogo Instalados do SDK e todos os problemas voam paira longe.

Escrevi na atividade
import com.google.android.gms.maps.SupportMapFragment;

e Eclipse me deu o ícone viewmelho> clique> corrigir configuration do projeto …> adicionair file google-play-services.jair

E finamente funcionou !!

Adicione services do Google Play ao seu projeto

Paira disponibilizair as APIs de services do Google Play paira sua aplicação:

siga as etapas presentes neste link: http://developer.android.com/google/play-services/setup.html#Setup

Eu enfrentei esse problema ao usair o Android SDK paira x86 em uma máquina Windows 7 de 64 bits. Eu baixei a viewsão do Android SDK de 64 bits, fiz o Eclipse view na window> Preferences> Android> localization do SDK e o problema pairou de ocorrer.

Por favor, leia atentamente

Se tudo está woking o mesmo que o google code, então viewifique o file manifesto no meu caso, eu adicionei a key geográfica e a key de mapa, é por isso que ocorre uma exception,

Nota – não adicione duas keys no file de manifesto, remova a tecla do mapa

 meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="@string/google_maps_key"/> 

adicione este código.

  <meta-data android:name="com.google.android.geo.API_KEY" android:value="@string/auto_location"/> <meta-data android:name="com.google.android.gms.viewsion" android:value="@integer/google_play_services_viewsion"/> 
Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.