Dev/Error

카메라 앱 열면서 앱 중지 android.os.FileUriExposedException

healthyryu 2017. 12. 22. 14:39

카메라 앱 열면서 앱 중지

android.os.FileUriExposedException



현상 : 카메라 앱 열면서 앱 중지


원인 : targetSdkVersion 을 올렸기 때문에 발생 (23 -> 26)

해결 : 이전대로 targetSkdVersion 을 낮추던지 아래와 같이 파일 접근 방법을 바꾸던지

Uri photoURI = FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".my.package.name.provider", createImageFile());


E/AndroidRuntime: FATAL EXCEPTION: main

Process: com.iofit.tablet, PID: 30756

android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/....../temp_thumbnail.png exposed beyond app through ClipData.Item.getUri()

    at android.os.StrictMode.onFileUriExposed(StrictMode.java:1799)

    at android.net.Uri.checkFileUriExposed(Uri.java:2346)

    at android.content.ClipData.prepareToLeaveProcess(ClipData.java:832)

    at android.content.Intent.prepareToLeaveProcess(Intent.java:9514)

    at android.content.Intent.prepareToLeaveProcess(Intent.java:9499)

    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1525)

    at android.app.Activity.startActivityForResult(Activity.java:4403)

    at android.support.v4.app.BaseFragmentActivityApi16.startActivityForResult(BaseFragmentActivityApi16.java:54)

    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:65)

    at android.support.v4.app.ActivityCompat.startActivityForResult(ActivityCompat.java:152)

    at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:789)

    at android.support.v4.app.FragmentActivity$HostCallbacks.onStartActivityFromFragment(FragmentActivity.java:898)

    at android.support.v4.app.Fragment.startActivityForResult(Fragment.java:1018)

    at android.support.v4.app.Fragment.startActivityForResult(Fragment.java:1007)

    .......


해결 방안https://stackoverflow.com/a/38858040/3897810


반응형