ImagePicker icon indicating copy to clipboard operation
ImagePicker copied to clipboard

NullPointerException on OnePlus3 Oreo

Open Ruben2112 opened this issue 7 years ago • 4 comments

I'm getting a crash on my device when I try this library, even when using the sample app available on the play store. I think it has something to do with Oreo because I'm pretty sure it worked before.

02-14 13:41:35.165 16726-16726/com.example.a.tdm2_v2 E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.a.tdm2_v2, PID: 16726 java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference at android.support.v4.content.FileProvider.parsePathStrategy(FileProvider.java:591) at android.support.v4.content.FileProvider.getPathStrategy(FileProvider.java:565) at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:403) at com.mvc.imagepicker.ImagePicker.getPickImageIntent(ImagePicker.java:219) at com.mvc.imagepicker.ImagePicker.startChooser(ImagePicker.java:189) at com.mvc.imagepicker.ImagePicker.pickImage(ImagePicker.java:180) at com.mvc.imagepicker.ImagePicker.pickImage(ImagePicker.java:138) at com.example.a.tdm2_v2.AddRiderFragment$1.onClick(AddRiderFragment.java:121) at android.view.View.performClick(View.java:6289) at android.view.View$PerformClick.run(View.java:24800) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6809) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

Ruben2112 avatar Feb 14 '18 12:02 Ruben2112

Same, having the same issue since I updated from 1.2.0 to 1.2.2. Reason of updating, having crashes on targetSdkVersion 24> But the issue was solved in https://github.com/Mariovc/ImagePicker/issues/39

PokerAsh avatar Feb 20 '18 12:02 PokerAsh

I am using 1.2.2, he says it's fixed in that version, but I'm still getting the same error.

Ruben2112 avatar Feb 20 '18 12:02 Ruben2112

I had the same issues and looked at the file providers. had to add the following code my the manifest

<provider android:name="android.support.v4.content.FileProvider" android:authorities="com.mvc.imagepicker.provider" android:exported="false" android:grantUriPermissions="true" tools:replace="android:authorities"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" tools:replace="android:resource"/> </provider>

file_paths.xml:

<?xml version="1.0" encoding="utf-8"?> <resources> <paths> <external-cache-path name="img" path="/" /> </paths> </resources> I hope it can help someone else.

athomaj avatar Mar 16 '18 20:03 athomaj

Add this to the application tag of your Android Manifest:


        <provider
            android:name="android.support.v4.content.FileProvider"
            android:authorities="com.mvc.imagepicker.provider"
            android:exported="false"
            android:grantUriPermissions="true"
            tools:replace="android:authorities">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/provider_paths"
                tools:replace="android:resource"/>
        </provider>

euri16 avatar May 10 '18 22:05 euri16