我得到了一些報告,從用戶體驗的背透crashlytics給我一個錯誤谷歌地圖CameraUpdateFactory未初始化
Fatal Exception java.lang.NullPointerException
CameraUpdateFactory is not initialized
這不是一個經常性的死機,因爲它不會出現爲每一個用戶,但它變得太經常,我需要解決它。
我讀了,如果地圖沒有被初始化,我想我已經覆蓋
if(googleMap!=null){
googleMap.animateCamera(CameraUpdateFactory.newLatLng(selectedLatLng));
}
也是一個可能原因可能是谷歌Play服務沒有設備或這可能發生已過時,我也爲此添加了一些驗證。
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(FuelsFragment.this.getActivity());
// Showing status
//CAMERAUPDATE FACTORY CRASH CAN BE A RESULT OF GOOGLE PLAY SERVICES NOT INSTALLED OR OUT OF DATE
//ADDITIONAL VERIFICATION ADDED TO PREVENT FURTHER CRASHES
//https://github.com/imhotep/MapKit/pull/17
if(status == ConnectionResult.SUCCESS)
{
mMapFragment = ReepMapFragment.newInstance();
FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction();
fragmentTransaction.add(R.id.mapContainer, mMapFragment);
fragmentTransaction.commit();
}
else if(status == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED){
reep.toastNotify("You need to update Google Play Services in order to view maps");
}
else if (status==ConnectionResult.SERVICE_MISSING){
reep.toastNotify("Google Play service is not enabled on this device.");
}
之後,我不確定接下來要做什麼,因爲這不會發生在每個用戶身上。
如果任何人有會出現這種情況我會很感激你輸入的任何想法
我已經涵蓋了已經在我的問題... –