我在用于裁剪图像的Google 相册应用程序上遇到意外崩溃
这是完整的崩溃日志:
2020-12-10 21:16:56.954 26763-27559/? E/DatabaseUtils: Writing exception to parcel
java.lang.IllegalArgumentException: MIME type application/octet-stream cannot be inserted into content://media/external/images/media/73119; expected MIME type under image/*
at com.android.providers.media.MediaProvider.ensureFileColumns(MediaProvider.java:2092)
at com.android.providers.media.MediaProvider.ensureNonUniqueFileColumns(MediaProvider.java:1964)
at com.android.providers.media.MediaProvider.updateInternal(MediaProvider.java:4711)
at com.android.providers.media.MediaProvider.update(MediaProvider.java:4518)
at android.content.ContentProvider$Transport.update(ContentProvider.java:420)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:215)
at android.os.Binder.execTransactInternal(Binder.java:1036)
at android.os.Binder.execTransact(Binder.java:1003)
--------- beginning of crash
2020-12-10 21:16:56.980 30404-30432/? E/AndroidRuntime: FATAL EXCEPTION: ptz-ui-2-GENERIC_BACKGROUND_TASK
Process: com.google.android.apps.photos, PID: 30404
aqxx: Error executing doInBackground in SaveEditTask
at _1784.a(PG:3)
at aqyd.k(PG:7)
at aqyd.o(PG:2)
at ltx.e(PG:1)
at ltx.d(PG:5)
at lts.fc(Unknown Source:5)
at aqyd.r(PG:6)
at aqyj.run(PG:14)
at avmb.run(PG:2)
at aqys.run(PG:2)
at avmb.run(PG:2)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:241)
at android.app.ActivityThread.main(ActivityThread.java:7617)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
Caused by: java.lang.IllegalArgumentException: MIME type application/octet-stream cannot be inserted into content://media/external/images/media/73119; expected MIME type under image/*
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:170)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140)
at android.content.ContentProviderProxy.update(ContentProviderNative.java:578)
at android.content.ContentResolver.update(ContentResolver.java:1993)
at lxr.g(PG:20)
at _649.i(PG:4)
at lux.b(PG:74)
at nad.b(PG:1)
at com.google.android.apps.photos.editor.SaveEditTask.w(PG:13)
at aqxp.a(Unknown Source:1)
at awrs.c(Unknown Source:2)
at awqu.run(PG:4)
at awru.run(PG:1)
at awpo.execute(PG:1)
at awqq.f(PG:2)
at aqxy.a(PG:1)
at aqxy.l(PG:6)
at aqyr.run(PG:2)
at avmb.run(PG:2)
at aqek.call(PG:1)
at aqfn.call(PG:1)
at aqer.run(PG:8)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
at aqea.run(PG:2)
我正在从相机拍摄照片,然后裁剪照片。
启动相机代码:
void launchCamera(String fileName) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE, null);
ContentValues contentValues = new ContentValues();
contentValues.put(MediaStore.Images.Media.DISPLAY_NAME, fileName);
contentValues.put(MediaStore.Images.Media.RELATIVE_PATH, Environment.DIRECTORY_PICTURES);
contentValues.put(MediaStore.Images.Media.MIME_TYPE, "image/*");
mCapturedPhotoUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
if (mCapturedPhotoUri != null) {
intent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedPhotoUri);
}
List<ResolveInfo> activities = getPackageManager().queryIntentActivities(intent, 0);
if (activities.isEmpty()) {
Log.i(TAG, "No activity found");
} else {
startActivityForResult(intent, RESULT_ACTIVITY_IMAGE_FROM_CAMERA);
}
}
作物意图代码:
void performCrop(String fileName) {
ContentValues contentValues = new ContentValues();
contentValues.put(MediaStore.Images.Media.DISPLAY_NAME, fileName);
contentValues.put(MediaStore.Images.Media.RELATIVE_PATH, Environment.DIRECTORY_PICTURES);
contentValues.put(MediaStore.Images.Media.MIME_TYPE, "image/*");
mCroppedPhotoUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
Intent intent = new Intent("com.android.camera.action.CROP");
intent.putExtra("crop", "true");
intent.setDataAndType(mCapturedPhotoUri, IMAGE_MIME_TYPE);
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra(MediaStore.EXTRA_OUTPUT, mCroppedPhotoUri);
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION
| Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivityForResult(intent, RESULT_ACTIVITY_IMAGE_CROP);
}
我可以从“mCroppedPhotoUri”中获得裁剪的图像,但在裁剪后大约 1/2 秒后Google 照片应用程序崩溃(使用 Google 照片进行裁剪)。我把崩溃日志放在帖子的顶部。
它发生在Android 10(Q)上,但在Android 11(R)上运行良好。
Device: motorola one
Android OS: 10
targetSdkVersion: 29
compileSdkVersion: 29
我在Google 照片应用程序上做错了什么或它的错误?