Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StartCameraIntent -> NullPointerException crash #47

Open
StephenMilone opened this issue May 10, 2017 · 7 comments
Open

StartCameraIntent -> NullPointerException crash #47

StephenMilone opened this issue May 10, 2017 · 7 comments

Comments

@StephenMilone
Copy link

Here is the crash log

Exception java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.io.File.getCanonicalPath()' on a null object reference
android.support.v4.content.FileProvider$SimplePathStrategy.getUriForFile (FileProvider.java:695)
android.support.v4.content.FileProvider.getUriForFile (FileProvider.java:400)
gun0912.tedbottompicker.TedBottomPicker.startCameraIntent (TedBottomPicker.java:414)
gun0912.tedbottompicker.TedBottomPicker.access$100 (TedBottomPicker.java:57)
gun0912.tedbottompicker.TedBottomPicker$3.onItemClick$5359dc9a (TedBottomPicker.java:275)
gun0912.tedbottompicker.adapter.ImageGalleryAdapter$1.onClick (ImageGalleryAdapter.java:180)
android.view.View.performClick (View.java:5612)

From a MotoZ running 7.0, using 1.0.12 of this library

Let me know whatever else I can do to help. thanks!

@ParkSangGwon
Copy link
Owner

@StephenMilone Did you granted WRITE_EXTERNAL_STORAGE permission?

@SPoporo
Copy link

SPoporo commented Jul 13, 2017

@StephenMilone this problem is in your TedBottomPicker code, line:408 'Uri photoURI = FileProvider.getUriForFile(getContext(), getContext().getApplicationContext().getPackageName() + ".provider", imageFile); ' . this error is authority name didn't end with ".provider". adding provider meta data

@kanxoramesh
Copy link

Hey how can i solve this issues ? any idea

@nickilanjelo
Copy link

This problem is still topical on Android API 29 (Android 10). Application can create files only in own directory. The problem is in this line:

File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);

I think that storageDir should be app directory.

As was first disclosed back in March 2019, you no longer have access by default to arbitrary locations on external storage or removable storage on Android 10+. This includes Environment.getExternalStorageDirectory() and other methods on Environment (e.g., getExternalStoragePublicDirectory().

https://stackoverflow.com/a/58379655

@ARRR42
Copy link

ARRR42 commented Mar 13, 2020

Temp solution: add to your manifest file

<application
...
android:requestLegacyExternalStorage="true"

@nickilanjelo
Copy link

I already do this, but in Android R this thing will be deprecated.

@dds861
Copy link

dds861 commented Jun 23, 2021

Now google asks to delete this android:requestLegacyExternalStorage="true", otherwise no updates will be allowed. So what we have to do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants