null array error en la aplicación de google maps V2 android

Estoy tratando de integrar google mapa en un fragmento … La aplicación estaba funcionando bien antes, pero de repente se estrelló

He comprobado los enlaces a continuación … Pero ninguno de estos trabajos para mí Intento de obtener la longitud de matriz nulo en google maps V2 android app

¿Por qué google map v2 de repente se estrelló por java.lang.NullPointerException: Intento de obtener la longitud de la matriz nula?

Mis códigos son:

@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); MapsInitializer.initialize(getActivity()); View bottomSheet = fragmentLayout.findViewById(R.id.bottomSheet); fap = (FloatingActionButton) fragmentLayout.findViewById(R.id.fap); fap.setOnClickListener(this); bottomSheetTitle = (TextView) fragmentLayout.findViewById(R.id.bottomSheetTitle); bottomSheetAddress = (TextView) fragmentLayout.findViewById(R.id.bottomSheetAddress); bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet); bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() { @Override public void onStateChanged(@NonNull View bottomSheet, int newState) { if (newState == BottomSheetBehavior.STATE_HIDDEN) { fap.setVisibility(View.GONE); // text1.setText("Collapse Me!"); } else { fap.setVisibility(View.VISIBLE); // text1.setText("Expand Me!"); } } @Override public void onSlide(@NonNull View bottomSheet, float slideOffset) { } }); bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); // getDetails(1); // bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); switch (GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity())) { case ConnectionResult.SUCCESS: Toast.makeText(getActivity(), "SUCCESS", Toast.LENGTH_SHORT).show(); mapView = (MapView) fragmentLayout.findViewById(R.id.map); if(mapView != null) mapView.onCreate(savedInstanceState); // Gets to GoogleMap from the MapView and does initialization stuff if (mapView != null) { Toast.makeText(getActivity(), "Getting map", Toast.LENGTH_SHORT).show(); mapView.getMapAsync(this); } break; case ConnectionResult.SERVICE_MISSING: Toast.makeText(getActivity(), "SERVICE MISSING", Toast.LENGTH_SHORT).show(); break; case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED: Toast.makeText(getActivity(), "UPDATE REQUIRED", Toast.LENGTH_SHORT).show(); break; default: // Toast.makeText(getActivity(), GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity()), Toast.LENGTH_SHORT).show(); break; } // googleMap.setMyLocationEnabled(true); } @Override public void onMapReady(GoogleMap googleMap) { // Toast.makeText(getActivity(), "Map is ready to use", Toast.LENGTH_SHORT).show(); this.map = googleMap; map.getUiSettings().setMyLocationButtonEnabled(false); if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. Toast.makeText(getActivity(), "Oops permission denied", Toast.LENGTH_SHORT).show(); return; } map.setMyLocationEnabled(true); map.getUiSettings().setMyLocationButtonEnabled(true); mClusterManager = new ClusterManager<Location>(getActivity(), map); map.setOnCameraIdleListener(new GoogleMap.OnCameraIdleListener() { @Override public void onCameraIdle() { // Toast.makeText(getActivity(), "camera moved", Toast.LENGTH_SHORT).show(); getLocationByRadius(map.getCameraPosition().target.latitude, map.getCameraPosition().target.longitude); } }); map.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() { @Override public void onCameraChange(CameraPosition cameraPosition) { getLocationByRadius(map.getCameraPosition().target.latitude, map.getCameraPosition().target.longitude); } }); map.setOnCameraIdleListener(mClusterManager); map.setOnMarkerClickListener(mClusterManager); mClusterManager.setOnClusterItemClickListener(new ClusterManager.OnClusterItemClickListener<Location>() { @Override public boolean onClusterItemClick(Location location) { getDetails(location.getLocationId()); return false; } }); checkPermission(); } 

Diseño xml:

 <android.support.design.widget.CoordinatorLayout 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" xmlns:app="http://schemas.android.com/apk/res-auto" tools:context="rollwithme.com.rollwithme.Fragments.ParkingFragment" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <com.google.android.gms.maps.MapView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/map" /> <include layout="@layout/fragment_location_details" /> <android.support.design.widget.FloatingActionButton android:src="@drawable/ic_expand_less_white_24dp" android:id="@+id/fap" app:fabSize="normal" android:layout_width="wrap_content" android:layout_height="wrap_content" app:layout_anchor="@id/bottomSheet" android:visibility="gone" app:backgroundTint="@color/colorPrimary" app:layout_anchorGravity="top|right|end" android:layout_marginRight="@dimen/cardViewPadding"/> </android.support.design.widget.CoordinatorLayout> 

Estoy probando en lg g3 ….. Aplicación funciona bien en Huawei Y6 Pro ….. utilizado para trabajar en g3 también …..

el mensaje de error que estoy recibiendo es

 FATAL EXCEPTION: main Process: rollwithme.com.rollwithme, PID: 4401 java.lang.NullPointerException: Attempt to get length of null array at maps.Gaa(Unknown Source) at maps.VNa(Unknown Source) at maps.Dea(Unknown Source) at maps.Dpa(Unknown Source) at maps.ad.ae.a(Unknown Source) at maps.ad.ta(Unknown Source) at maps.ad.Ra(Unknown Source) at uo.onTransact(:com.google.android.gms.DynamiteModulesB:66) at android.os.Binder.transact(Binder.java:380) at com.google.android.gms.maps.internal.IMapViewDelegate$zza$zza.onCreate(Unknown Source) at com.google.android.gms.maps.MapView$zza.onCreate(Unknown Source) at com.google.android.gms.dynamic.zza$3.zzb(Unknown Source) at com.google.android.gms.dynamic.zza$1.zza(Unknown Source) at com.google.android.gms.maps.MapView$zzb.zzbru(Unknown Source) at com.google.android.gms.maps.MapView$zzb.zza(Unknown Source) at com.google.android.gms.dynamic.zza.zza(Unknown Source) at com.google.android.gms.dynamic.zza.onCreate(Unknown Source) at com.google.android.gms.maps.MapView.onCreate(Unknown Source) at rollwithme.com.rollwithme.Fragments.ParkingFragment.onActivityCreated(ParkingFragment.java:163) at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:2089) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1133) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1290) at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:801) at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1638) at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:679) at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:143) at android.support.v4.view.ViewPager.populate(ViewPager.java:1240) at android.support.v4.view.ViewPager.populate(ViewPager.java:1088) at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1614) at android.view.View.measure(View.java:17496) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5464) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1438) at android.widget.LinearLayout.measureVertical(LinearLayout.java:724) at android.widget.LinearLayout.onMeasure(LinearLayout.java:615) at android.view.View.measure(View.java:17496) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5464) at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:700) at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:767) at android.view.View.measure(View.java:17496) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5464) at android.widget.FrameLayout.onMeasure(FrameLayout.java:430) at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135) at android.view.View.measure(View.java:17496) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5464) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1438) at android.widget.LinearLayout.measureVertical(LinearLayout.java:724) at android.widget.LinearLayout.onMeasure(LinearLayout.java:615) at android.view.View.measure(View.java:17496) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5464) at android.widget.FrameLayout.onMeasure(FrameLayout.java:430) at android.view.View.measure(View.java:17496) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5464) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1438) at android.widget.LinearLayout.measureVertical(LinearLayout.java:724) at android.widget.LinearLayout.onMeasure(LinearLayout.java:615) at android.view.View.measure(View.java:17496) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5464) at android.widget.FrameLayout.onMeasure(FrameLayout.java:430) at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2636) at android.view.View.measure(View.java:17496 

One Solution collect form web for “null array error en la aplicación de google maps V2 android”

No podría solucionarlo usando el mapview Más adelante cambié a supportMapFragment …. Y resolvió mi problema … Gracias a google

Para otros seguí los siguientes enlaces … Gracias 🙂

https://developers.google.com/android/reference/com/google/android/gms/maps/SupportMapFragment

https://developers.google.com/maps/documentation/android-api/map

  • Mapas fuera de línea SDK para Android e iOS
  • Uso del Espresso a la prueba unitaria Google Maps
  • Límites de cuotas de Android Geocoder
  • Google Maps lento en WebView de Android 2.2 cuando se utilizan transformaciones CSS3
  • La API de Google Maps v2 no funciona
  • Dibujar la polilínea a la aplicación Android google maps
  • Google map dentro de otro fragmento - Error al llamar a getMapAsync
  • Geocoder getFromLocation () no es nulo pero tiene el tamaño 0 siempre
  • Cómo configurar android mapa sdk v2 para utilizar diferentes claves para la producción y el desarrollo?
  • Obtener país de coordenadas?
  • Cómo obtener la latitud y la longitud en el mapa en Android?
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.