使用react-native-image-picker

时间:2018-05-30 13:52:03

标签: react-native

使用react-native-image-picker选择对话框中的两个选项之一('拍摄照片​​'或从图书馆中选择')时,应用程序崩溃。

其他信息

  • React Native version:0.55.3
  • react-native-image-picker version:0.26.7

这是显示图像选择器的功能

_showImagePicker(userImageType) {
    const isImage = userImageType != 'videoUrl';
    var options = {
        title: translate(isImage ? 'PROFILE_EDITOR_SELECT_IMAGE' : 'PROFILE_EDITOR_SELECT_VIDEO'),
        cancelButtonTitle: translate('IMAGE_PICKER_CANCEL_BUTTON_TITLE'),
        takePhotoButtonTitle: translate('IMAGE_PICKER_TAKE_PHOTO_BUTTON_TITLE'),
        chooseFromLibraryButtonTitle: translate('IMAGE_PICKER_FROM_LIBRARY_BUTTON_TITLE'),
        mediaType: userImageType != 'videoUrl' ? 'photo' : 'video',
        noData: 'true',
        videoQuality: 'low',
        storageOptions: {
            skipBackup: true,
            path: 'captures'
        }
    };
    ImagePicker.showImagePicker(options, (response) => {
        console.log('Response = ', response);
        if (response.didCancel) {
            return;
        }
        else if (response.error) {
            Alert.alert(response.error);
            return;
        }
        else {
            let source = response.uri;
            if (userImageType != 'videoUrl' && response.fileSize > (6 * 1024 * 1024)) {
                Alert.alert(translate("DEFAULT_ERROR_TITLE"), translate('PROFILE_EDITOR_IMAGE_SIZE_EXCEEEDS_MAX'));
                return;
            }
            // You can also display the image using data:
            // let source = {uri: 'data:image/jpeg;base64,' + response.data };
            if (userImageType != 'videoUrl') {
                this._processProfileData(userImageType, source);
            } else {
                // Updated. Adapted to new server format
                this._processProfileData(userImageType, source)
            }
        }
    });
}

记录器:

  

05-30 11:33:15.481 8285 8359 E AndroidRuntime:FATAL EXCEPTION:mqt_native_modules   05-30 11:33:15.481 8285 8359 E AndroidRuntime:进程:com.tripbru.tripper.dev,PID:8285   05-30 11:33:15.481 8285 8359 E AndroidRuntime:java.lang.ClassCastException:java.lang.String无法强制转换为java.lang.Boolean   05-30 11:33:15.481 8285 8359 E AndroidRuntime:at com.facebook.react.bridge.ReadableNativeMap.getBoolean(ReadableNativeMap.java:137)   05-30 11:33:15.481 8285 8359 E AndroidRuntime:at com.imagepicker.ImagePickerModule.parseOptions(ImagePickerModule.java:708)   05-30 11:33:15.481 8285 8359 E AndroidRuntime:at com.imagepicker.ImagePickerModule.launchImageLibrary(ImagePickerModule.java:321)   05-30 11:33:15.481 8285 8359 E AndroidRuntime:at com.imagepicker.ImagePickerModule.launchImageLibrary(ImagePickerModule.java:302)   05-30 11:33:15.481 8285 8359 E AndroidRuntime:at com.imagepicker.ImagePickerModule $ 2.onUseLibrary(ImagePickerModule.java:172)   05-30 11:33:15.481 8285 8359 E AndroidRuntime:at com.imagepicker.utils.UI $ 1.onClick(UI.java:58)   05-30 11:33:15.481 8285 8359 E AndroidRuntime:在android.support.v7.app.AlertController $ AlertParams $ 3.onItemClick(AlertController.java:1044)

0 个答案:

没有答案