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

java.lang.IllegalArgumentException: MIME type #90

Open Normalnick12 opened 2 years ago

Normalnick12 commented 2 years ago

Hi!

Describe the bug

Crash app

To Reproduce

Steps to reproduce the behavior:

  1. Open AddMediaScreen.
  2. Click on "Add Video" or "Add Audio"
    java.lang.IllegalArgumentException: MIME type video/mp4 cannot be inserted into content://media/external/images/media; expected MIME type under image/*
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:172)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
        at android.content.ContentProviderProxy.insert(ContentProviderNative.java:549)
        at android.content.ContentResolver.insert(ContentResolver.java:2149)
        at android.content.ContentResolver.insert(ContentResolver.java:2111)
        at com.google.modernstorage.storage.AndroidFileSystem.createMediaStoreUri(AndroidFileSystem.kt:425)
        at com.google.modernstorage.sample.mediastore.MediaStoreViewModel$addMedia$1.invokeSuspend(MediaStoreViewModel.kt:76)

    It seems to fix the error you need to change the following: in MediaStoreViewModel change field "Collection" For video ->

    collection = MediaStore.Video.Media.getContentUri("external")

    For Audio ->

    collection = MediaStore.Audio.Media.getContentUri("external")
mrsinhloi commented 11 months ago

Thanks you @Normalnick12 . I am fixed.

vsoftphuong commented 11 months ago

I am too. Thanks @Normalnick12