12

파일 제공 업체를 사용하여 사진을 지정된 대상에 저장하고 있습니다. 내가 얻을 :Android 파일 제공자 잘못된 인수 예외

java.lang.IllegalArgumentException가 : 누락 android.support.FILE_PROVIDER_PATHS 메타 데이터를 카메라에서 이미지를 캡처하는 활동을 열려고하는 동안.

내 manifest.xml 파일 :

<provider 
android:name="android.support.v4.content.FileProvider" 
android:authorities="com.example" 
android:exported="false" 
android:grantUriPermissions="true"> 
    <meta-data 
    android:name="android.support.FILE_PROVIDER_PATHS" 
    android:resource="@xml/paths" /> 
</provider> 

내 paths.xml 파일 :

<paths xmlns:android="http://schemas.android.com/apk/res/android"> 
    <external-path name="content" path="Android/data/com.my_package_name/files/" /> 
</paths> 

및 Java 코드 :

File externalFilesDirectory = this.getExternalFilesDir(null); 
File imageFile = File.createTempFile(
     imageFileName, 
     ".jpg", 
     externalFilesDirectory 
); 
Uri photoURI = FileProvider.getUriForFile(this, "com.example", imageFile); 

마지막 라인은 예외를 제공합니다. 여기에 무엇이 누락 되었습니까? 공식 Android 개발 사이트 (https://developer.android.com/training/camera/photobasics.html)에서 자습서를 따라했습니다.

+0

자습서 링크를 추가 할 수 있습니까? –

+0

예, 끝났습니다. –

+0

'com.example'은''com.example "'이어야합니다. 그게 고칠 수 있니? –

답변

15

해결책을 찾았습니다. 문제는 내 권위 이름이 ".fileprovider"로 끝나지 않았다는 것입니다. 결정된.

+0

괜찮습니다. 그것은 그들이 이상한 것처럼 보입니다. –

+0

FileProvider 권한 이름이 ".fileprovider"로 끝나야한다는 것을 요구하는 문서에 대한 링크를 제공 할 수 있습니까? – anticafe

+0

https://developer.android.com/reference/android/support/v4/content/FileProvider.html#ProviderDefinition – Arst