Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
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
Crash on Android 11 #23
Crash on Android 11 #23
Comments
Describe the bug
Application crashes when gligar activity is launched (After allow permissions for the first time too).
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Show the list of local image files.
Include stack trace if exist
E/ThemeUtils: View class androidx.appcompat.widget.AppCompatTextView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
E/ThemeUtils: View class androidx.appcompat.widget.AppCompatTextView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
E/AndroidRuntime: FATAL EXCEPTION: main
Process: avanceingenieros.com.app, PID: 6152
java.lang.IllegalArgumentException: Invalid token LIMIT
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:172)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:472)
at android.content.ContentResolver.query(ContentResolver.java:1183)
at android.content.ContentResolver.query(ContentResolver.java:1115)
at android.content.ContentResolver.query(ContentResolver.java:1071)
at com.opensooq.supernova.gligar.dataSource.ImagesDataSource.loadAlbumImages(ImagesDataSource.kt:64)
at com.opensooq.supernova.gligar.ui.PickerViewModel$getImages$2.invokeSuspend(PickerViewModel.kt:99)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
Smartphone (please complete the following information):
The text was updated successfully, but these errors were encountered:
You need to remove the LIMIT from ImageDataSource -> loadAlbumImages function
You need to remove the LIMIT from ImageDataSource -> loadAlbumImages function
How to limit users to select only one image from galary.
How to limit users to select only one image from galary.
-> you can use new GligarPicker().requestCode(PICKER_REQUEST_CODE).limit(1). limit function like this but it wont help you, stil it is crashing.
Yes, I have tried many ways but I think there is a permission-related issue which must have to fix in the library.
Now roll back to own ways of Gallery and Camera taking photos.
I fixed the issues for Android 11, please use this class:
internal class ImagesDataSource(private val contentResolver: ContentResolver)
fun getCursorUri(): Uri < val collection: Uri if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) < collection = newCursorUri; >else < collection = cursorUri; >return collection; > fun loadAlbums(): ArrayList < val albumCursor = contentResolver.query( getCursorUri(), arrayOf(DISPLAY_NAME_COLUMN, MediaStore.Images.ImageColumns.BUCKET_ID), null, null, ORDER_BY ) val list = arrayListOf() try < list.add(AlbumItem("All", true, "0")) if (albumCursor == null) < return list >albumCursor.doWhile < try < val bucketId = albumCursor.getString(albumCursor.getColumnIndex(MediaStore.Images.ImageColumns.BUCKET_ID)) val name = albumCursor.getString(albumCursor.getColumnIndex(DISPLAY_NAME_COLUMN)) ?: bucketId var albumItem = AlbumItem(name, false, bucketId) if (!list.contains(albumItem)) < list.add(albumItem) >> catch (ex: Exception) < ex.printStackTrace() >> > finally < if (albumCursor != null && !albumCursor.isClosed) < albumCursor.close() >> return list > fun loadAlbumImages( albumItem: AlbumItem?, page: Int ): ArrayList < val offset = page * PAGE_SIZE val list: ArrayList= arrayListOf() var photoCursor: Cursor? = null try < if (Build.VERSION.SDK_INT >Build.VERSION_CODES.Q) < val bundle = Bundle().apply < putInt(ContentResolver.QUERY_ARG_LIMIT, PAGE_SIZE) putInt(ContentResolver.QUERY_ARG_OFFSET, offset) putString(ContentResolver.QUERY_ARG_SQL_SORT_ORDER, "$DESC") > photoCursor = contentResolver.query( getCursorUri(), arrayOf( ID_COLUMN, PATH_COLUMN ), bundle, null ) > else < if (albumItem == null || albumItem.isAll) < photoCursor = contentResolver.query( getCursorUri(), arrayOf( ID_COLUMN, PATH_COLUMN ), null, null, "$ORDER_BY LIMIT $PAGE_SIZE OFFSET $offset" ) >else < photoCursor = contentResolver.query( getCursorUri(), arrayOf( ID_COLUMN, PATH_COLUMN ), "$=?", arrayOf(albumItem.bucketId), "$ORDER_BY LIMIT $PAGE_SIZE OFFSET $offset" ) > > photoCursor?.isAfterLast ?: return list photoCursor.doWhile < try < val image = photoCursor.getString((photoCursor.getColumnIndex(PATH_COLUMN))) list.add(ImageItem(image, ImageSource.GALLERY, 0)) >catch (ex: Exception) < ex.printStackTrace() >> > finally < if (photoCursor != null) < if (!photoCursor.isClosed()) < photoCursor.close() >> > return list >
Hello, Can you guide me how to edit «ImagesDataSource» file. Its showing file is read only.
@Shay-BH
What to place in «newCursorUri» in Constant
Hi @Shay-BH @sumeet3110. Can you please guide me what to place as newCursorUri.
Thanks!
@HassanGlixenTech you need to place it in Const.kt
@HassanGlixenTech you need to place it in Const.kt
@AlexStroia What could be the value of that constant. If you can guide me that would be really helpful as i am newbie at this topic.
@ateeqrehman33 Hi you have to make this library as a dependency to your project (Download it and add it your project) then you will able to edit ImageDataSource file..
@ateeqrehman33 I already have access to ImageDataSource. I just need to find out what can be the value placed at this position
@HassanGlixenTech I have used the same as cursorUri and it is working for me .
Still getting this error, has it been FIXED ?
Kindly merge the pull request Yazan98 this user already fixed all the issues. My bad luck i am using it in my main application. For now i import it as a module and fixed it on my side but its a temporary fix that i did .. i am waiting for your update.
Kindly merge the pull request Yazan98 this user already fixed all the issues. My bad luck i am using it in my main application. For now i import it as a module and fixed it on my side but its a temporary fix that i did .. i am waiting for your update.
Thanks
Please tell me the solution to this problem. I could not solve the problem with what was said
I fixed the issues for Android 11, please use this class:
internal class ImagesDataSource(private val contentResolver: ContentResolver)
fun getCursorUri(): Uri < val collection: Uri if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) < collection = newCursorUri; >else < collection = cursorUri; >return collection; > fun loadAlbums(): ArrayList < val albumCursor = contentResolver.query( getCursorUri(), arrayOf(DISPLAY_NAME_COLUMN, MediaStore.Images.ImageColumns.BUCKET_ID), null, null, ORDER_BY ) val list = arrayListOf() try < list.add(AlbumItem("All", true, "0")) if (albumCursor == null) < return list >albumCursor.doWhile < try < val bucketId = albumCursor.getString(albumCursor.getColumnIndex(MediaStore.Images.ImageColumns.BUCKET_ID)) val name = albumCursor.getString(albumCursor.getColumnIndex(DISPLAY_NAME_COLUMN)) ?: bucketId var albumItem = AlbumItem(name, false, bucketId) if (!list.contains(albumItem)) < list.add(albumItem) >> catch (ex: Exception) < ex.printStackTrace() >> > finally < if (albumCursor != null && !albumCursor.isClosed) < albumCursor.close() >> return list > fun loadAlbumImages( albumItem: AlbumItem?, page: Int ): ArrayList < val offset = page * PAGE_SIZE val list: ArrayList= arrayListOf() var photoCursor: Cursor? = null try < if (Build.VERSION.SDK_INT >Build.VERSION_CODES.Q) < val bundle = Bundle().apply < putInt(ContentResolver.QUERY_ARG_LIMIT, PAGE_SIZE) putInt(ContentResolver.QUERY_ARG_OFFSET, offset) putString(ContentResolver.QUERY_ARG_SQL_SORT_ORDER, "$DESC") > photoCursor = contentResolver.query( getCursorUri(), arrayOf( ID_COLUMN, PATH_COLUMN ), bundle, null ) > else < if (albumItem == null || albumItem.isAll) < photoCursor = contentResolver.query( getCursorUri(), arrayOf( ID_COLUMN, PATH_COLUMN ), null, null, "$ORDER_BY LIMIT $PAGE_SIZE OFFSET $offset" ) >else < photoCursor = contentResolver.query( getCursorUri(), arrayOf( ID_COLUMN, PATH_COLUMN ), "$=?", arrayOf(albumItem.bucketId), "$ORDER_BY LIMIT $PAGE_SIZE OFFSET $offset" ) > > photoCursor?.isAfterLast ?: return list photoCursor.doWhile < try < val image = photoCursor.getString((photoCursor.getColumnIndex(PATH_COLUMN))) list.add(ImageItem(image, ImageSource.GALLERY, 0)) >catch (ex: Exception) < ex.printStackTrace() >> > finally < if (photoCursor != null) < if (!photoCursor.isClosed()) < photoCursor.close() >> > return list >
I could not add this project as a package to my project so I could edit it!
Please explain how to add and edit this project to our project .
implementation 'com.github.omkar-tenkale:Gligar:78d8110102e0be4e1e2f939b5307ae5f645e6761'
implementation 'com.opensooq.supernova:gligar:1.1.0'
implementation 'com.github.omkar-tenkale:Gligar:78d8110102e0be4e1e2f939b5307ae5f645e6761'
implementation 'com.opensooq.supernova:gligar:1.1.0'
thank you
I tried your method
But again an error occurred
And the program crashed
try
File > Invalid caches/Restart
E/AndroidRuntime: FATAL EXCEPTION: main Process: it.nexid.ivoting, PID: 11134 java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/lifecycle/ViewModelKt; at com.opensooq.supernova.gligar.ui.PickerViewModel.loadAlbums$gligar_release(PickerViewModel.kt:80) at com.opensooq.supernova.gligar.ui.ImagePickerActivity.loadAlbums(ImagePickerActivity.kt:137) at com.opensooq.supernova.gligar.ui.ImagePickerActivity.storagePermissionGranted(ImagePickerActivity.kt:142) at com.opensooq.supernova.gligar.ui.ImagePickerActivity.checkStoragePermission(ImagePickerActivity.kt:190) at com.opensooq.supernova.gligar.ui.ImagePickerActivity.onResume(ImagePickerActivity.kt:406) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1456) at android.app.Activity.performResume(Activity.java:8353) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4889) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4936) at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2317) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:246) at android.app.ActivityThread.main(ActivityThread.java:8595) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130) Caused by: java.lang.ClassNotFoundException: Didn’t find class «androidx.lifecycle.ViewModelKt» on path: DexPathList[[zip file «/data/app/~~TKOg2FjMjw4LEPP7lLtf9w==/it.nexid.ivoting-mr-dzpUGyp5Y-8l8aVapFw==/base.apk»],nativeLibraryDirectories=[/data/app/~~TKOg2FjMjw4LEPP7lLtf9w==/it.nexid.ivoting-mr-dzpUGyp5Y-8l8aVapFw==/lib/arm64, /system/lib64, /system/system_ext/lib64]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at com.opensooq.supernova.gligar.ui.PickerViewModel.loadAlbums$gligar_release(PickerViewModel.kt:80) at com.opensooq.supernova.gligar.ui.ImagePickerActivity.loadAlbums(ImagePickerActivity.kt:137) at com.opensooq.supernova.gligar.ui.ImagePickerActivity.storagePermissionGranted(ImagePickerActivity.kt:142) at com.opensooq.supernova.gligar.ui.ImagePickerActivity.checkStoragePermission(ImagePickerActivity.kt:190) at com.opensooq.supernova.gligar.ui.ImagePickerActivity.onResume(ImagePickerActivity.kt:406) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1456) at android.app.Activity.performResume(Activity.java:8353) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4889) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4936) at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2317) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:246) at android.app.ActivityThread.main(ActivityThread.java:8595) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130) V/FA: Connection attempt already in progress V/FA: Connection attempt already in progress I/Process: Sending signal. PID: 11134 SIG: 9
i try
File > Invalid caches/Restart but no effect
I tried this
The program crashed again
Regarding crash java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/lifecycle/ViewModelKt; at
This doesnt occur to me nor it seems related to lib
you can try
Add the dependencies in the build.gradle of the app in my scenario was using a library that needed those dependencies
Make sure android X is enabled with gradle.properties and Jetfier enabled
android.useAndroidX=true android.enableJetifier=true