Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setImageUri java.io.FileNotFoundException: open failed: ENOENT (No such file or directory) #577

Closed
NightXlt opened this issue Oct 5, 2019 · 9 comments

Comments

@NightXlt
Copy link

NightXlt commented Oct 5, 2019

same happens on latest version, as reported in #426 . I am testing on xiaomi6 with api26. The uCrop is the latest version 'com.github.yalantis:ucrop:2.2.4'.

And here is how i create destinationUri:
            val sourceUri = Uri.fromFile(File(path))
            val image = File.createTempFile(fileName, ".jpg", cacheDir)
            val destinationUri = Uri.fromFile(image)

related manifest lines:

   <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="com.example.constraintlayout.apkgfileprovider"
            android:grantUriPermissions="true"
            android:exported="false">
        <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/filepaths" />
    </provider>

Error after camera intent:
java.io.FileNotFoundException: /external_file_image/CroppedProfileImage.jpg (No such file or directory)

image pick works.

I use: getUriForFile(this, this.applicationContext.packageName + ".apkgfileprovider", image) doenn't work, and the error log is same.

 E/TransformImageView: onFailure: setImageUri
    java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)
@Apples0609
Copy link

你好,你这个问题解决了吗?
hi,Have you solved the problem?

@luckysmg
Copy link

在安卓10上,我用下面的方法解决了,前提是你要有图片的文件路径
On android 10, I solved this problem using the following method, provided you have the file path of the image
F1E412EA-E884-4710-B518-A66389B27B19

@Apples0609
Copy link

已经换用,android-image-cropper库了,谢了啊兄弟

@abdulrehmank7
Copy link

I was facing the same problem. Now i have found the solution. Check out here:

https://medium.com/@arkapp/accessing-images-on-android-10-scoped-storage-bbe65160c3f4?source=friends_link&sk=675c33e4595709bce43461ad01154391

@Marina24
Copy link

duplicate to #598

@Shouheng88
Copy link

I thinks there is nothing todo with Android Q.

Use Uri.fromFile() instead of FileProvider.getUriForFile() to get the output uri. Judging from its source code, it uses Uri.getPath() to get the output path. But uri from provider and from file was different. Uri.getPath() won't return the real file path on the file system, so it caused FileNotFoundException.

For details see BitmapLoadTask#onPostExecute() method.

@gurpreet433
Copy link

duplicate to #598

no it is not

@rahul4452
Copy link

I was facing the same problem. Now i have found the solution. Check out here:

https://medium.com/@arkapp/accessing-images-on-android-10-scoped-storage-bbe65160c3f4?source=friends_link&sk=675c33e4595709bce43461ad01154391

Thanks for the link. It's really helpful.

@EzequielAdrianM
Copy link

Please take a look at this answer from StackOverflow, there's a class that converts content provider URI's to a real File path that will not give you FileNotFound exception.

https://stackoverflow.com/a/42153974/4612755

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants