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

Nothing happens: openPicker or openCamera #1260

Closed
tapz opened this issue Apr 1, 2020 · 14 comments
Closed

Nothing happens: openPicker or openCamera #1260

tapz opened this issue Apr 1, 2020 · 14 comments

Comments

@tapz
Copy link

tapz commented Apr 1, 2020

Version

Tell us which versions you are using:

  • react-native-image-crop-picker v0.28.0
  • react-native v0.62.0

Platform

Tell us to which platform this issue is related

  • Android 9, Samsung S8+

Expected behaviour

Open gallery or camera

Actual behaviour

Nothing happens.

Steps to reproduce

const image = await ImagePicker.openCamera({
  width: 512,
  height: 512,
  cropping: true
});

OR

const image = await ImagePicker.openPicker({
  width: 512,
  height: 512,
  cropping: true
});

Attachments

MyApp.MainActivity                   onUserLeaveHint 
MyApp.MainActivity                   onPause 
ViewRootImpl@c903598[MainActivity]   MSG_WINDOW_FOCUS_CHANGED 0 1 
InputMethodManager                   prepareNavigationBarInfo() DecorView@575667f[MainActivity] 
InputMethodManager                   getNavigationBarColor() -855310 
MainApplication                      getReactNativeHost 
MainApplication                      getReactNativeHost 
ViewRootImpl@c903598[MainActivity]   MSG_WINDOW_FOCUS_CHANGED 1 1 
InputMethodManager                   prepareNavigationBarInfo() DecorView@575667f[MainActivity] 
InputMethodManager                   getNavigationBarColor() -855310 
MainApplication                      getReactNativeHost 
MainApplication                      getReactNativeHost 
MyApp.MainActivity                   onRequestPermissionsResult: 1 
ViewRootImpl@c903598[MainActivity]   setWindowStopped(false) old=false 
MyApp.MainActivity                   onResume 
System.out                           (HTTPLog)-Static: isSBSettingEnabled false 
System.out                           (HTTPLog)-Static: isSBSettingEnabled false 
ViewRootImpl@c903598[MainActivity]   Relayout returned: old=[0,0][1080,2220] new=[0,0][1080,2220] result=0x1 surface={valid=true 479528591360} changed=false 
MyApp.MainActivity$ConnBCastReceiver ConnBCastReceiver.onReceive: android.net.conn.CONNECTIVITY_CHANGE 
System                               A resource failed to call end.  
chatty                               uid=10298(com.myapp) FinalizerDaemon identical 2 lines 
System                               A resource failed to call end.  	
@tapz
Copy link
Author

tapz commented Apr 2, 2020

Works in iPhone X, but Cancel and Choose after taking a photo are not localized.

Does not work in Google Pixel 2, Android 10 either, so probably something wrong in the Android implementation or permissions. I have my own permissions handling in my app as it uses camera and mic. Maybe the lib cannot handle this and the callback goes to my code when it should go to the lib. This can be seen in the log line onRequestPermissionsResult: 1. If this is the case, it should be fixed in the lib.

@tapz
Copy link
Author

tapz commented Apr 2, 2020

I changed my code to use requestPermissions from the ReactActivity not from ActivityCompat and removed the onRequestPermissionsResult (using a callback). Now I'm getting the following error even though the camera permission has already been granted:

Failed to open camera. [Error: Required permission missing]

@tapz
Copy link
Author

tapz commented Apr 2, 2020

BTW. Why is WRITE_EXTERNAL_STORAGE always requested? is it really required to have a WRITE access to the external storage to get images from the gallery or camera?

@tapz
Copy link
Author

tapz commented Apr 2, 2020

I had to request the WRITE_EXTERNAL_STORAGE permission myself to get it working. Still really don't understand why this is needed for just using the camera and why it needs to be WRITE, not READ?

@wbercx
Copy link

wbercx commented Apr 3, 2020

I suspect it has to do with the compression this library tries to do. It compresses any image you choose, regardless of whether it came from the camera or the file system, and writes it to disk and gives you its URI.

@tapz
Copy link
Author

tapz commented Apr 3, 2020

But I only need a base64 version. Don't know if that can be done in memory.

@tapz
Copy link
Author

tapz commented Apr 3, 2020

The big question, however is, why do I need to request the permissions and the lib's permission request does not work?

@tapz
Copy link
Author

tapz commented Apr 3, 2020

One more problem is that cancelling image selection throws an error. Am I supposed to compare the error description to "User cancelled image selection". I'm sure there could be a better way.

Error: User cancelled image selection]

@tapz
Copy link
Author

tapz commented Apr 6, 2020

With Pixel 3, Android 10 I get this even when the user has given both READ and WRITE permissions. This does not happen in Samsung S8 and Android 9.

TransformImageView	 onFailure: setImageUri	
TransformImageView	 java.io.FileNotFoundException: open failed: EACCES (Permission denied)	
TransformImageView	 	at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:315)	
TransformImageView	 	at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:220)	
TransformImageView	 	at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1498)	
TransformImageView	 	at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:1338)	
TransformImageView	 	at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:1286)	
TransformImageView	 	at com.yalantis.ucrop.task.BitmapLoadTask.doInBackground(BitmapLoadTask.java:100)	
TransformImageView	 	at com.yalantis.ucrop.task.BitmapLoadTask.doInBackground(BitmapLoadTask.java:44)	
TransformImageView	 	at android.os.AsyncTask$3.call(AsyncTask.java:378)	
TransformImageView	 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)	
TransformImageView	 	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)	
TransformImageView	 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)	
TransformImageView	 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)	
TransformImageView	 	at java.lang.Thread.run(Thread.java:919)	
image-crop-picker	 Promise rejected. Cannot find image data	

@tapz
Copy link
Author

tapz commented Apr 6, 2020

Looks like the lib is not compatible with Android 10 and a workaround in the manifest is needed.

https://stackoverflow.com/questions/32524001/java-io-filenotfoundexception-open-failed-eacces-permission-denied

@juanjsebgarcia
Copy link

I'm also seeing this issue manifest itself on Android 10.

android:requestLegacyExternalStorage="true"
Adding this to AndroidManifest alleviates the issue, but this workaround will not work with Android 11 in the future.

@tapz
Copy link
Author

tapz commented Apr 23, 2020

android:requestLegacyExternalStorage is just a workaround. Unless checking the permissions are fixed, this lib will stop working in the future.

@ivpusic
Copy link
Owner

ivpusic commented May 1, 2020

please try https://github.com/ivpusic/react-native-image-crop-picker/releases/tag/v0.30.0

@juanjsebgarcia
Copy link

I can confirm that's fixed, I deleted android:requestLegacyExternalStorage and bumped the package version and my AndroidX device is working as expected.

Thanks so much!

@ivpusic ivpusic closed this as completed May 2, 2020
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

4 participants