[개발] flutter - android 파일 첨부 처리
개요
스팀잇 사이트에서 파일을 첨부하기 위해 필요한 준비사항을 기술
오류
Couldn't find meta-data for provider with authority
flutter webview 에서 사진 첨부시 오류 해결
W/System.err(29993): java.lang.IllegalArgumentException: Couldn't find meta-data for provider with authority com
해결
1. 파일수정
: android/app/src/main/AndroidManifest.xml
아래와 같이 추가
...xml
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="me.albie.share"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
...
</application>
</manifest>
2. 폴더생성
: android/app/src/main/res/xml
3. 파일생성
: android/app/src/main/res/xml/file_paths.xml
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path
name="storage/emulated/0"
path="."/>
</paths>
결과물
모바일 키체인을 구현하여 파일을 업로드 할 수 있다. 물론 카메라로 바로 사진을 찍어 업로드 할 수도 있음.
참조링크
- https://developer.android.com/reference/androidx/core/content/FileProvider
- https://stackoverflow.com/questions/42516126/fileprovider-illegalargumentexception-failed-to-find-configured-root
- https://developer.android.com/training/camera/photobasics?hl=ko#kotlin
- https://developer.android.com/training/secure-file-sharing/setup-sharing?hl=ko