aloisdeniel / media_gallery

A Flutter plugin that lists native gallery items.
MIT License
87 stars 33 forks source link

App crashes on Android 11 - SDK 30 (Invalid token LIMIT in getCollectionThumbnail) #28

Open AdrianSima opened 3 years ago

AdrianSima commented 3 years ago

After settings compiledSdkVersion to 30 the app crashes every time I try to get collections or medias.

E/AndroidRuntime( 6991):    at android.os.AsyncTask$4.done(AsyncTask.java:415)
E/AndroidRuntime( 6991):    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
E/AndroidRuntime( 6991):    at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
E/AndroidRuntime( 6991):    at java.util.concurrent.FutureTask.run(FutureTask.java:271)
E/AndroidRuntime( 6991):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
E/AndroidRuntime( 6991):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AndroidRuntime( 6991):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime( 6991):    at java.lang.Thread.run(Thread.java:923)
E/AndroidRuntime( 6991): Caused by: java.lang.IllegalArgumentException: Invalid token LIMIT
E/AndroidRuntime( 6991):    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:172)
E/AndroidRuntime( 6991):    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
E/AndroidRuntime( 6991):    at android.content.ContentProviderProxy.query(ContentProviderNative.java:472)
E/AndroidRuntime( 6991):    at android.content.ContentResolver.query(ContentResolver.java:1183)
E/AndroidRuntime( 6991):    at android.content.ContentResolver.query(ContentResolver.java:1115)
E/AndroidRuntime( 6991):    at android.content.ContentResolver.query(ContentResolver.java:1071)
E/AndroidRuntime( 6991):    at com.example.media_gallery.MediaGalleryPlugin.getCollectionThumbnail(MediaGalleryPlugin.kt:427)
E/AndroidRuntime( 6991):    at com.example.media_gallery.MediaGalleryPlugin.access$getCollectionThumbnail(MediaGalleryPlugin.kt:20)
E/AndroidRuntime( 6991):    at com.example.media_gallery.MediaGalleryPlugin$onMethodCall$7.invoke(MediaGalleryPlugin.kt:92)
E/AndroidRuntime( 6991):    at com.example.media_gallery.MediaGalleryPlugin$onMethodCall$7.invoke(MediaGalleryPlugin.kt:20)
E/AndroidRuntime( 6991):    at com.example.media_gallery.doAsync.doInBackground(MediaGalleryPlugin.kt:538)
E/AndroidRuntime( 6991):    at com.example.media_gallery.doAsync.doInBackground(MediaGalleryPlugin.kt:532)
E/AndroidRuntime( 6991):    at android.os.AsyncTask$3.call(AsyncTask.java:394)
E/AndroidRuntime( 6991):    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
E/AndroidRuntime( 6991):    ... 4 more
Lost connection to device.

The error seems to be in the getCollectionThumbnail() function with: "Invalid token LIMIT".

Tested this on Android Emulator with Pixel 4XL API 30 and media_gallery: 0.1.5.

AdrianSima commented 3 years ago

It works fine now after using this fork by @miyura https://github.com/Geostry/media_gallery by changing this in pubspec.yaml:

dependencies:
    media_gallery:
        git:
          url: git://github.com/Geostry/media_gallery.git
Ahmadre commented 3 years ago

@aloisdeniel can we merge the fixes?

benwinding commented 3 years ago

Thanks @AdrianSima !

The only thing I would add, is that it's much safer to use the exact commit on the git repo, as the current master branch is broken. I use the following code:

  media_gallery:
    # Fixes issue: https://github.com/aloisdeniel/media_gallery/issues/28
    git:
      url: git://github.com/Geostry/media_gallery
      ref: f5b30c7298f01dcc1589b6ac450888010c0da9f3

That way future updates, to these forks, won't break the app