#react-native #expo #react-native-camera
Вопрос:
Я пытаюсь сохранить видео на свою камеру в React Native на Android, консоль отлично возвращает uri видео, но я получаю ошибку.
Error: Unable to copy file into external storage.
Однако при вводе кода в Snack он работает нормально. Только не тогда, когда я делаю
react-native run-android
Вот журналы консоли
[Mon Aug 02 2021 21:03:30.108] LOG Video source: file:///data/user/0/com.allies.ai/cache/Camera/74eb667a-a799-4f4e-8d80-98261580c36e.mp4
[Mon Aug 02 2021 21:03:32.222] WARN Possible Unhandled Promise Rejection (id: 0):
Error: Unable to copy file into external storage.
promiseMethodWrapper@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:4552:45
http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:109931:40
saveToLibraryAsync$@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:228365:95
tryCatch@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:25289:23
invoke@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:25462:32
tryCatch@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:25289:23
invoke@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:25362:30
http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:25392:19
tryCallTwo@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:27386:9
doResolve@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:27550:25
Promise@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:27409:14
callInvokeWithMethodAndArg@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:25391:33
enqueue@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:25396:157
async@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:25413:69
saveToLibraryAsync@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:228352:38
recordVideo$@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:228022:48
tryCatch@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:25289:23
invoke@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:25462:32
tryCatch@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:25289:23
invoke@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:25362:30
http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:25372:21
tryCallOne@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:27377:16
http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:27478:27
_callTimer@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:30917:17
_callImmediatesPass@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:30956:17
callImmediates@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:31173:33
__callImmediates@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:5034:35
http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:4820:34
__guard@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:5017:15
flushedQueue@http://localhost:8081/index.bundle?platform=androidamp;dev=trueamp;minify=false:4819:21
flushedQueue@[native code]
invokeCallbackAndReturnFlushedQueue@[native code]
Вот код на закуску:
https://snack.expo.dev/@ptang/camera
заранее спасибо.
Ответ №1:
Так что для тех, у кого аналогичная проблема — Android 10 теперь использует так называемое хранилище областей. Короче говоря, существуют ограничения на сохранение в вашей фотопленке, в настоящее время нет никакой работы над ответом для expo-камеры ИЛИ react-native-cameraroll.
Единственное временное исправление-добавить следующую строку:
android:requestLegacyExternalStorage="true"
к вашему AndroidManifest.xml файл, в частности, в разделе «Деятельность»:
<manifest>
...
<application>
...
<activity android:name=".MainActivity"
android:requestLegacyExternalStorage="true">
...
</activity>
...
</application>
...
</manifest>
Комментарии:
1. Какие-нибудь решения для экспо?
2. Не работает. Ошибка все еще сохраняется.