Open b3da-cz opened 7 years ago
hm, do you have some time to debug this? I cannot reproduce issue on my android devices
Hmmm... i am also getting this crash either when selecting the image from camera or from gallery. I only get this error on an Android 4.4.2 Samsung S4 device. However it works well on Android devices > 5.0.0
that log is from Nexus 5x (with Android 7.1.1), but it's randomly crashing on most phones / Android versions (mostly > 5.0) on which I tested it..
I'll try to get some more details.
@b3da-cz that would be very helpful. Thanks
@b3da-cz it is funny that on my nexus5x it is working fine :/. Did you try example project?
After some more testing, i have realized that the crash only occurs in Android OS devices below 5.0.0 (i tested on a 4.4.2 device) when cropping is set to true (cropping:true). The crash occurs on the device and a 4.4.2 emulator. If cropping is set to false, the image can be selected and the app does not crash on device or emulator.
can you try example project with your 4.4.2 devices? I have some 4.3 which works great, but no 4.4.2 :/.
Same problem on Android 5.0, cropping: false didnt helped...
Tried on my Nexus 5X with 7.1.1 and it happens even without cropping... but I actually don't think it's a crash - no system alert appears after it happens, the app is only restarted after accepting the photo. Seems that the original activity of the app (or the app itself?) gets killed for some reason after going to the camera and so after leaving the camera, the app just starts again without any error.
EDIT On my phone, it does not happen when Debug JS Remotely option is on, it only happens when debugging is off. Maybe this can help reproduce.
@danielrys would be very helpful if you could turn on android studio, run app from there, and provide stacktrace here
ok, so this is basically what the log looks like after opening the camera:
02-23 16:53:16.538 883 893 I ActivityManager: START u0 act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=com.google.android.GoogleCamera/com.android.camera.activity.CaptureActivity clip={text/uri-list U:content://com.xxxx.xxxx.provider/app_images/Android/data/com.xxxx.xxxx/files/Pictures/image-ea7b6837-6fef-430f-9fdb-41fa169800e2.jpg} (has extras)} from uid 10171 on display 0
02-23 16:53:30.006 883 25132 I WindowManager: WIN DEATH: Window{e604e5b u0 com.xxxx.xxxx/com.xxxx.xxxx.MainActivity}
02-23 16:53:30.008 883 11499 I ActivityManager: Process com.xxxx.xxxx (pid 30652) has died
Seems that the whole app process stops.
Did anyone manage to fix this>?
Same issue here...
Same issue here, doesn't appear to be related to Android < 5.0 though. I can see the same "restart" behavior on Android 6.0
I also can see the same "restart" behavior on Android 6.0.1
Hot to fix:
Make sure you are using gradle 2.2.x:
classpath 'com.android.tools.build:gradle:2.2.3' Add this in your app gradle:
android { ... defaultConfig { ... vectorDrawables.useSupportLibrary true ... }
Thank to @sfratini
@Clowning that fix did not work for me. App still restarting immediately after taking a picture and confirming.
Android 6.0 RN 0.44
@dgurns did you found any solution for this?
Nope, I had to use react-native-image-picker instead
@dgurns I was using react-native-image-picker
and decided to use this library because of the exact same behaviour. I think it's related to the OS and not to the library (https://github.com/react-community/react-native-image-picker/issues/732)
I found out I do get:
E/CAM_StateSavePic: exception while saving result to URI: Optional.of(content://com.test.app.android.provider/app_images/Pictures/image-5900b551-fd35-485e-997b-a8eadfe32b397411249060724805767.jpg)
java.io.FileNotFoundException: No content provider: content://com.test.app.android.provider/app_images/Pictures/image-5900b551-fd35-485e-997b-a8eadfe32b397411249060724805767.jpg
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1251)
at android.content.ContentResolver.openOutputStream(ContentResolver.java:1007)
at android.content.ContentResolver.openOutputStream(ContentResolver.java:983)
at cys.e(PG:18)
at cys.b(PG:52)
at cni.b(PG:13)
at cni.a(PG:38)
at cyh.a(PG:5)
at emm.run(PG:8)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
though.
Any update on this? I also came here because react-native-image-picker
has the same behavior.
I think this is something related to available memory because doesn't happen on my emulator, just on the physical device.
I also need an update for this! Android App crashes after taking Photo and confirming (before cropping). It reopens, then everything works fine (cropping and saving works then. Why?)
@Clowning thx, that works for me.
if you guys have memory issue, it's probably similar to this https://github.com/ivpusic/react-native-image-crop-picker/issues/519
I fixed this by asking the permissions on Android and iOS (using react-native-permissions lib):
useEffect(() => {
async function askPermissions() {
if (Platform.OS === 'android') {
await Permissions.requestMultiple([
'android.permission.CAMERA',
'android.permission.WRITE_EXTERNAL_STORAGE',
]);
}
if (Platform.OS === 'ios') {
await Permissions.requestMultiple(['ios.permission.CAMERA', 'ios.permission.PHOTO_LIBRARY']);
}
}
askPermissions();
}, []);
com.android.tools.build:gradle
My Gradle version is 3.4.1 what should I do ?
Version
Tell us which versions you are using:
Platform
Android
Expected behaviour
to show cropper and save photo
Actual behaviour
crash right after photo confirmation, when taken new image from camera, almost every time
Steps to reproduce
open camera from app
take picture, confirm it
crash
Attachments