Join FlipAndroid.COM Telegram Group: https://t.me/joinchat/F_aqThGkhwcLzmI49vKAiw


Android studio v0.3.2, gradle, google maps v2.0 No encontró la clase "com.google.android.gms.maps.MapFragment

Tengo problema con Google Maps Android v2.0. Porque intento muchas opciones y siempre consigo este stacktrace:

1-03 17:39:26.015 2398-2398/com.** E/AndroidRuntime﹕ FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{com.**/com.** .MainActivity}: android.view.InflateException: Binary XML file line #24: Error inflating class fragment at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) at android.app.ActivityThread.access$600(ActivityThread.java:141) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5041) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) at dalvik.system.NativeStart.main(Native Method) Caused by: android.view.InflateException: Binary XML file line #24: Error inflating class fragment at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) at android.view.LayoutInflater.inflate(LayoutInflater.java:489) at android.view.LayoutInflater.inflate(LayoutInflater.java:396) at android.view.LayoutInflater.inflate(LayoutInflater.java:352) at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270) at android.app.Activity.setContentView(Activity.java:1881) at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:208) at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:111) at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:76) at com.**.MainActivity.onCreate(MainActivity.java:43) at android.app.Activity.performCreate(Activity.java:5104) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)             at android.app.ActivityThread.access$600(ActivityThread.java:141)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)             at android.os.Handler.dispatchMessage(Handler.java:99)             at android.os.Looper.loop(Looper.java:137)             at android.app.ActivityThread.main(ActivityThread.java:5041)             at java.lang.reflect.Method.invokeNative(Native Method)             at java.lang.reflect.Method.invoke(Method.java:511)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)             at dalvik.system.NativeStart.main(Native Method) Caused by: android.support.v4.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 at android.support.v4.app.Fragment.instantiate(Fragment.java:409) at android.support.v4.app.Fragment.instantiate(Fragment.java:377) at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:277) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)             at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)             at android.view.LayoutInflater.inflate(LayoutInflater.java:489)             at android.view.LayoutInflater.inflate(LayoutInflater.java:396)             at android.view.LayoutInflater.inflate(LayoutInflater.java:352)             at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)             at android.app.Activity.setContentView(Activity.java:1881)             at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:208)             at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:111)             at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:76)             at com.**.MainActivity.onCreate(MainActivity.java:43)             at android.app.Activity.performCreate(Activity.java:5104)             at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)             at android.app.ActivityThread.access$600(ActivityThread.java:141)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)             at android.os.Handler.dispatchMessage(Handler.java:99)             at android.os.Looper.loop(Looper.java:137)             at android.app.ActivityThread.main(ActivityThread.java:5041)             at java.lang.reflect.Method.invokeNative(Native Method)             at java.lang.reflect.Method.invoke(Method.java:511)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)             at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.MapFragment" on path: /data/app/com.**-2.apk at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65) at java.lang.ClassLoader.loadClass(ClassLoader.java:501) at java.lang.ClassLoader.loadClass(ClassLoader.java:461) at android.support.v4.app.Fragment.instantiate(Fragment.java:399)             at android.support.v4.app.Fragment.instantiate(Fragment.java:377)             at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:277)             at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)             at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)             at android.view.LayoutInflater.inflate(LayoutInflater.java:489)             at android.view.LayoutInflater.inflate(LayoutInflater.java:396)             at android.view.LayoutInflater.inflate(LayoutInflater.java:352)             at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)             at android.app.Activity.setContentView(Activity.java:1881)             at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:208)             at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:111)             at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:76)             at com.**.MainActivity.onCreate(MainActivity.java:43)             at android.app.Activity.performCreate(Activity.java:5104)             at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)             at android.app.ActivityThread.access$600(ActivityThread.java:141)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)             at android.os.Handler.dispatchMessage(Handler.java:99)             at android.os.Looper.loop(Looper.java:137)             at android.app.ActivityThread.main(ActivityThread.java:5041)             at java.lang.reflect.Method.invokeNative(Native Method)             at java.lang.reflect.Method.invoke(Method.java:511)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)             at dalvik.system.NativeStart.main(Native Method) 

Mi build.grade:

  buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.6.+' } } apply plugin: 'android' repositories { mavenCentral() } android { compileSdkVersion 19 buildToolsVersion "19" defaultConfig { minSdkVersion 8 targetSdkVersion 19 } } dependencies { compile 'com.google.android.gms:play-services:3.1.36' // compile 'com.google.android.gms:play-services:+' //3.2.25 compile 'com.android.support:support-v4:19.0.+' compile 'com.android.support:appcompat-v7:19.0.+' } 

Mi manifiesto:

 <?xml version="1.0" encoding="utf-8"?> 

 <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="18" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="*****"/> <activity android:name="com.*.NonLoggedActivity" android:configChanges="orientation|keyboardHidden|screenSize" android:label="@string/app_name" android:theme="@style/FullscreenTheme" > </activity> <activity android:name="com.*.LoginActivity" android:label="@string/title_activity_login" android:windowSoftInputMode="adjustResize|stateVisible" > </activity> <activity android:name="com.*.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> <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"/> <permission android:name="com.*.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.*.permission.MAPS_RECEIVE" /> <uses-feature android:glEsVersion="0x00020000" android:required="true"/> <uses-library android:name="com.google.android.maps" android:required="false" /> 

En activity_main.xml:

  <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"/> 

Administrador de Sdk: Introduzca aquí la descripción de la imagen

Y Estructura del proyecto: Introduzca aquí la descripción de la imagen

¿Alguna idea de lo que está mal?

  • Instrucciones API en Android
  • Utilidad de mapas de Android: imágenes de la URL
  • Uso de Google MapView v2 en Live Wallpaper
  • Google google maps agrega al marcador propia etiqueta
  • Android animateCamera GoogleMap.CancelableCallback Uso
  • OnMapReady no llamando aunque la visualización del mapa sin ningún error
  • Mapa personalizado de Google Maps Engine en Android Maps v2?
  • Aplicación de setRotation a Maps API v2
  • 3 Solutions collect form web for “Android studio v0.3.2, gradle, google maps v2.0 No encontró la clase "com.google.android.gms.maps.MapFragment”

    Puede resolver este problema cuando cambia las dependencias a:

      dependencies { // compile 'com.google.android.gms:play-services:3.1.36' compile 'com.google.android.gms:play-services:3.2.25' //3.2.25 compile 'com.android.support:support-v4:19.0.+' compile 'com.android.support:appcompat-v7:19.0.+' } 

    Y escribir esto en la línea de comandos

     sudo . gradlew clean sudo . gradlew build sudo . gradlew installDebug 

    He intentado esto en Android Studio, pero cuando lo hice a través de la consola de mi aplicación ejecutar correctamente.

    Otra solución:

    Proyecto de reconstrucción en el estudio android:

     Build->rebuild project 

    Un problema es que te pierdas esto:

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

    Por lo tanto, cualquier solución no tendrá éxito, porque enmascarado por este otro problema.

    FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.