首页 > 解决方案 > Crashlytics android 11 设备在捕获照片和打开画廊时崩溃

问题描述

我有一个在以下版本的 android 上运行良好的应用程序,同时在 Android 11 版本上进行操作以获取应用程序崩溃的图库和相机捕捉图片。它向我显示以下代码的错误。我在这里从设备获取图像并在网格视图中显示以及捕获图片并设置到所需位置。

protected String doInBackground(String... args) {
                    String xml = "";
                    String path = null;
                    String album = null;
                    String timestamp = null;
                    String countPhoto = null;
                    Uri uriExternal = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
                    Uri uriInternal = android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI;
        
                    String[] projection = {MediaStore.MediaColumns.DATA, MediaStore.Images.Media.BUCKET_DISPLAY_NAME, MediaStore.MediaColumns.DATE_MODIFIED };
        //It is showing me error on below line of cursor
                    Cursor cursorExternal = Objects.requireNonNull(getActivity()).getContentResolver().query(uriExternal, projection, "_data IS NOT NULL) GROUP BY (bucket_display_name",
                            null, null);
                    Cursor cursorInternal = getActivity().getContentResolver().query(uriInternal, projection, "_data IS NOT NULL) GROUP BY (bucket_display_name",
                            null, null);
                    Cursor cursor = new MergeCursor(new Cursor[]{cursorExternal,cursorInternal});
        
                    while (cursor.moveToNext()) {
        
                        path = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA));
                        album = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.BUCKET_DISPLAY_NAME));
                        timestamp = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATE_MODIFIED));
                        if((timestamp == null || timestamp.isEmpty()))
                        {
                            timestamp="1111";
                        }
                        // System.out.println("Time stamp"+album+timestamp);
                        countPhoto = Function.getCount(getActivity(), album);
                        albumList.add(new GalleryGridData(album, path, timestamp, countPhoto,isSelecetd));
                    }
                    cursor.close();
                    return xml;
                }

错误是:

             Caused by: android.database.sqlite.SQLiteException: near "GROUP": syntax error (code 1 SQLITE_ERROR): , while compiling: SELECT _data, bucket_display_name, date_modified FROM images WHERE ((is_pending=0) AND (is_trashed=0)) AND ((_data IS NOT NULL) GROUP BY (bucket_display_name))
                at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:184)
                at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140)
                at android.content.ContentProviderProxy.query(ContentProviderNative.java:437)
                at android.content.ContentResolver.query(ContentResolver.java:962)
                at android.content.ContentResolver.query(ContentResolver.java:890)
                at android.content.ContentResolver.query(ContentResolver.java:846)
               

标签: androidgroup-bymysql-error-1064android-11cameracapturetask

解决方案


推荐阅读