Firelands128 / photo_gallery

A Flutter plugin that retrieves images and videos from mobile native gallery.
BSD 3-Clause "New" or "Revised" License
68 stars 63 forks source link

Fatal Exception and Crash on Android 11 #11

Closed richardbushnell closed 3 years ago

richardbushnell commented 4 years ago

On Android Emulator with SDK 30, calling listMedia fails with a FATAL EXCEPTION, causing the application to crash.

The stack trace contains the following: Caused by: java.lang.IllegalArgumentException: Invalid token LIMIT

I've traced this down to the contentResolver.query used in the listMedia method of the Kotlin plugin. It uses the syntax of sortOrder with a LIMIT and OFFSET. Apparently this is no longer valid in Android 11.

See this post for details: https://stackoverflow.com/questions/10390577/limiting-number-of-rows-in-a-contentresolver-query-function

If I get a chance, I'll try to fix it and create a pull request for you.

Firelands128 commented 3 years ago

Supported Android 11 by using Bundle in contentResolver query in version 0.4.0.