google / modernstorage

ModernStorage is a group of libraries that provide an abstraction layer over storage on Android to simplify its interactions
https://google.github.io/modernstorage/
Apache License 2.0
1.24k stars 60 forks source link

IllegalArgumentException: Mutation of _data is not allowed when target Android 14 #110

Open SteinerOk opened 9 months ago

SteinerOk commented 9 months ago

Describe the bug

I try use modernstorage to file downloading, but when update target to Android 14 start receive this exception

java.lang.IllegalArgumentException: Mutation of _data is not allowed.
                                                                                                    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:172)
                                                                                                    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
                                                                                                    at android.content.ContentProviderProxy.insert(ContentProviderNative.java:589)
                                                                                                    at android.content.ContentResolver.insert(ContentResolver.java:2209)
                                                                                                    at android.content.ContentResolver.insert(ContentResolver.java:2171)
                                                                                                    at com.google.modernstorage.storage.AndroidFileSystem.createMediaStoreUri(AndroidFileSystem.kt:425)

Environment:

numankaraaslan commented 6 months ago

This is happening when saving my video file too.

ContentValues values = new ContentValues(4);
values.put(MediaStore.Video.Media.TITLE, video_id + ".mp4");
values.put(MediaStore.Video.Media.DISPLAY_NAME, video_id + ".mp4");
values.put(MediaStore.Video.Media.MIME_TYPE, "video/mp4");
values.put(MediaStore.Video.Media.DATA, new File(file_path).getAbsolutePath());
getContentResolver().insert(MediaStore.Video.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY), values);

with the same stack trace.