在我的一加 6 上打开相机一段时间后,我一直遇到 react-native-image-picker 和 react-native-image-crop-picker 的问题。使用打开相机时,打开相机的后台应用程序(我的应用程序)崩溃。它进入白屏并重新启动应用程序。此外,react-native log-android 中没有日志。我确实设法使用 android studio 和 logcat 发现,一旦相机打开,应用程序就会立即崩溃并留下一个死进程。问题是我找不到任何实际的崩溃日志。虽然事先我得到了很多“访问拒绝找到属性“vendor.debug.egl.swapinterval””,但经过一些研究后似乎并不相关。
目前这个问题只发生在我的一加 6T 上。这些问题不会出现在模拟器或 IOS 上。即使不是在我尝试过的 xiamoi 设备上。
我已经尝试了所有方法,从在图像裁剪选择器(代码一)中压缩图像,到尝试压缩图像并在 react-native-image-picker 中使用 noData 标志(代码二)。另外,100%有权限,甚至可以在Android系统的权限中看到App permmision => {my app} 而且,我尝试清理我的一加6t相机的缓存,卸载-重新安装我的应用程序,并将开发者选项重置为默认。
我基本上已经在 github 中为这两个库解决了所有问题,但没有任何效果。
ImagePicker.openCamera({
width: 800,
height: 600,
compressImageMaxWidth: 640,
compressImageMaxHeight: 480,
compressImageQuality: 0.8
}).then(image => {
console.log(image);
}).catch(e => console.log(e));
ImagePicker.launchCamera({noData: true, maxWidth: 800, maxHeight: 600, quality: 0.8}, (response) => {
console.log('Response = ', response);
if (response.didCancel) {
console.log('User cancelled image picker');
} else if (response.error) {
console.log('ImagePicker Error: ', response.error);
} else if (response.customButton) {
console.log('User tapped custom button: ', response.customButton);
} else {
console.log(response)
}
});
添加我的清单:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="------">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
<uses-feature android:name="android.hardware.camera.front" android:required="false" />
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:largeHeap="true"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="true"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
android:launchMode="singleTop"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="io.invertase.firebase.messaging.RNFirebaseInstanceIdService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider" android:exported="false"
android:grantUriPermissions="true"> <meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" /> </provider>
</application>
</manifest>
预期的结果是收回承诺。并且应用程序在打开相机时不会崩溃。
很想得到一些输入。我现在有这个问题超过 2 周了。