Mariovc / ImagePicker

Android library to easily pick an image from gallery or camera app. The users can select their prefered gallery/camera app on a unique Intent. Initial gist:
https://gist.github.com/Mariovc/f06e70ebe8ca52fbbbe2
Apache License 2.0
158 stars 52 forks source link

NullPointerException on OnePlus3 Oreo #43

Open Ruben2112 opened 6 years ago

Ruben2112 commented 6 years ago

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)

PokerAsh commented 6 years ago

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

Ruben2112 commented 6 years ago

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

athomaj commented 6 years ago

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

` I hope it can help someone else.

euri16 commented 6 years ago

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>