Open shutupzk opened 7 years ago
are you sure you have react-native v0.44 installed? try running ./gradlew clean
Hi! I`m having a similar issue that was posted here.
Tell us which versions you are using:
Tell us to which platform this issue is related
In my case, the error shown is this: << -- E/unknown:ReactNative: Exception in native call java.lang.ClassCastException: host.exp.exponent.MainActivity cannot be cast to com.facebook.react.modules.core.PermissionAwareActivity at com.reactnative.ivpusic.imagepicker.PickerModule.permissionsCheck(PickerModule.java:233) at com.reactnative.ivpusic.imagepicker.PickerModule.openPicker(PickerModule.java:375) at java.lang.reflect.Method.invoke(Native Method) at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:374) at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162) at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31) at android.os.Looper.loop(Looper.java:158) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194) at java.lang.Thread.run(Thread.java:818)
-- >>
If you need further info, please ask for it without hesitate.
Thanks in advance :)
@favioConV did you fix the problem?
Hi @apzuk3! Sadly i haven't fixed yet. Sorry for the late response. Hope you can find it.
I got the same problem when integrating the react native app to an existing android app. The react-native-image-picker
has the option to implement OnImagePickerPermissionsCallback
to solve that problem.
Unfortunately this part is missing in react-native-image-crop-picker. It would be nice if that problem could get a fix.
How did you solve this issue? @karvulf
I found a very simple solution. To whatever Activity you are launching image picker from, add this code:
import com.facebook.react.modules.core.PermissionAwareActivity;
import com.facebook.react.modules.core.PermissionListener;
....
public class MyActivity extends Activity implements PermissionAwareActivity {
private PermissionListener permissionListener;
....
@TargetApi(Build.VERSION_CODES.M)
public void requestPermissions(String[] permissions, int requestCode, PermissionListener listener) {
permissionListener = listener;
requestPermissions(permissions, requestCode);
}
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (permissionListener != null && permissionListener.onRequestPermissionsResult(requestCode, permissions, grantResults)) {
permissionListener = null;
}
}
}
Version
Tell us which versions you are using:
Platform
Tell us to which platform this issue is related
Attachments
can not run ...
// stacktrace or any other useful debug info java.lang.ClassCastException: com.founder.doctor_app.MainActivity cannot be cast to com.facebook.react.modules.core.PermissionAwareActivity at com.reactnative.ivpusic.imagepicker.PickerModule.permissionsCheck(PickerModule.java:221) at com.reactnative.ivpusic.imagepicker.PickerModule.openPicker(PickerModule.java:349) at java.lang.reflect.Method.invoke(Native Method) at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:368) at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:138) at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:761) at android.os.Handler.dispatchMessage(Handler.java:98) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31) at android.os.Looper.loop(Looper.java:156) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:208) at java.lang.Thread.run(Thread.java:776)