Crash in Marshmallow Fragment Activity for Maps

筅森魡賤 提交于 2019-12-05 06:32:18
Heena Arora

The Issue was on "Micro-max Android one mobile" which was 6.0 Marshmallow. this device has not enough internal or external memory space.Even does not have SD card.

After following answer of George from this :

NullPointerException from Google maps

i installed memory card and now crash is not coming.

So i found problem was Updated Google Play services which require Space (updated Google photos ) that was not enough in my device.

and also one of the Error line was showing "Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.io.File.mkdir()' on a null object reference"

i decided to check after installing SD-card. And it worked

<!-- EXTERNAL_STORAGE permissions are optional for Android 6.0 onwards. -->
    <uses-permission
        android:name="android.permission.WRITE_EXTERNAL_STORAGE"
        android:maxSdkVersion="22" />
    <uses-permission
        android:name="android.permission.READ_EXTERNAL_STORAGE"
        android:maxSdkVersion="22" />

Add this to your manifest. Maybe maps need sdcard permission for some extra caching or something.

The issue has been fixed in version 9.0.83 of Google Play Services library.

This is just a workaround I did. If the below check fails, instead of loading the map, I load a fragment with an error.

/** Checks if external storage is available for read and write */
public boolean isExternalStorageWritable() {
    String state = Environment.getExternalStorageState();
    return Environment.MEDIA_MOUNTED.equals(state);
}

Add SD card permissions to your manifest file.

    <uses-permission
    android:name="android.permission.WRITE_EXTERNAL_STORAGE"
     />

    <uses-permission
    android:name="android.permission.READ_EXTERNAL_STORAGE"
    />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!