CameraRoll don';t在android上以react native显示图像
我的react原生项目中有此代码CameraRoll don';t在android上以react native显示图像,android,react-native,Android,React Native,我的react原生项目中有此代码 CameraRoll.getPhotos({ first: 20, assetType: "Photos", }).then((answer) => { dispatch({ type: PHOTOS_LIBRARY, photos: answer.edges, }); console.log(answer.edges); })
CameraRoll.getPhotos({
first: 20,
assetType: "Photos",
}).then((answer) => {
dispatch({
type: PHOTOS_LIBRARY,
photos: answer.edges,
});
console.log(answer.edges);
})
.catch((err) => {
console.log(err);
});
它在我的旧android设备上运行良好,但在模拟器和更强大的设备上不起作用,它不显示照片,事实上,它返回照片的对象,但具有空维度。
此console.log:
[{"fileSize": null, "filename": null, "height": null, "id": 0, "playableDuration": null,
"uri": "file:///storage/emulated/0/DCIM/Camera/IMG_20200902_153713.jpg", "width": null},
{"fileSize": null, "filename": null, "height": null, "id": 1, "playableDuration": null, "uri":
"file:///storage/emulated/0/DCIM/Camera/IMG_20200902_153653.jpg", "width": null}]
您是否尝试过在CameraRoll.getPhotos()方法中使用include? 例:
galaxy A50和SDK版本29也有同样的问题 修复此问题,将此行添加到:
android/app/src/main/AndroidManifest.xml
<application
...
android:requestLegacyExternalStorage="true"
...
android:theme="@style/AppTheme">
是的,谢谢,它可以工作,我已经解决了这个问题。)另外,您需要从@react native community/CameraRoll导入CameraRoll
<application
...
android:requestLegacyExternalStorage="true"
...
android:theme="@style/AppTheme">