Closed yc654084303 closed 6 years ago
I am getting the same issue any solution for this ? Android 7
If android api level 24 < add this one if(Build.VERSION.SDK_INT>=24){ try{ Method m = StrictMode.class.getMethod("disableDeathOnFileUriExposure"); m.invoke(null); }catch(Exception e){ e.printStackTrace(); } }
Please check out last ucrop version, it fixed
@Legementarion same happens on latest version, as reported in #406 . I am testing on emulator with api26. Issue is related with fileProvider URI. My fileprovider is:
<paths>
<!--For Context.getExternalFilesDir(Environment.DIRECTORY_PICTURES)-->
<external-files-path
name="external_file_image"
path="Pictures"/>
...
And here is how i create destinationUri:
val storageDir = context.getExternalFilesDir(Environment.DIRECTORY_PICTURES)
val file = File(storageDir, "CroppedProfileImage.jpg)
val destUri = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
try {
FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".file_provider", this)
} catch (e: Exception) {
e.printStackTrace()
null
}
} else {
Uri.fromFile(this)
}
related manifest lines:
<!-- For FileProvider API>=24 -->
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.file_provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_provider"/>
</provider>
Error after camera intent:
java.io.FileNotFoundException: /external_file_image/CroppedProfileImage.jpg (No such file or directory)
Error for image pick intent:
java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)
Works if i use:Uri.fromFile(new File(getCacheDir(), destinationFileName))
java.io.FileNotFoundException: /external_files/crop/imagecrop-1514552301831.jpg (No such file or directory) at java.io.FileOutputStream.open(Native Method) at java.io.FileOutputStream.(FileOutputStream.java:221)
at java.io.FileOutputStream.(FileOutputStream.java:169)
at com.yalantis.ucrop.task.BitmapLoadTask.copyFile(BitmapLoadTask.java:199)
at com.yalantis.ucrop.task.BitmapLoadTask.processInputUri(BitmapLoadTask.java:176)
at com.yalantis.ucrop.task.BitmapLoadTask.doInBackground(BitmapLoadTask.java:90)
at com.yalantis.ucrop.task.BitmapLoadTask.doInBackground(BitmapLoadTask.java:41)
at android.os.AsyncTask$2.call(AsyncTask.java:316)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:255)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:776)