我正在尝试从我的 android 应用程序中捕获相机图像。基本上,我试图通过在启动相机应用程序时将内容 uri(指向应用程序内部存储)传递到相机应用程序来实现这一点。但不幸的是,在我的应用程序打开相机活动后立即发生以下崩溃。控制没有进入内容提供者,所以它甚至在控制到达我的应用程序之前就崩溃了。相机应用程序因以下错误而崩溃。
请让我知道我缺少什么。androidmanifest.xml 中的内容提供者声明
<provider
android:name="a.b.c.provider.MediaStoreProvider"
android:authorities="a.b.c.mediastore"
android:enabled="true"
android:exported="true"/>
public static Uri generateMediaImageUri(long accountId) {
String fileName = "";
String uniqueKey = getUniqueKey();
// Create an image file name
String timeStamp = NAME_FORMATTER.format(new Date());
fileName = String.format(IMAGE_PREFIX, accountId) + timeStamp + uniqueKey + IMAGE_SUFFIX;
return Uri.parse("content://a.b.c.mediastore/image").buildUpon()
.appendPath(Long.toString(accountId))
.appendPath(fileName)
.build();
}
private Intent createCameraIntent() {
mMediaImageUri = MediaStoreProvider.generateMediaImageUri(mAccount.mId);
final Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, mMediaImageUri);
return cameraIntent;
}
2020-11-15 13:59:37.036 997-8747/? D/ACDB-LOADER: ACDB -> send_afe_topology
2020-11-15 13:59:37.036 997-8747/? D/ACDB-LOADER: ACDB -> ACDB_CMD_GET_AFE_TOPOLOGY_ID
2020-11-15 13:59:37.036 997-8747/? D/ACDB-LOADER: ACDB -> GET_AFE_TOPOLOGY_ID for adcd_id 513, Topology Id 10000ccc
2020-11-15 13:59:37.036 997-8747/? D/ACDB-LOADER: ACDB -> send_afe_cal
2020-11-15 13:59:37.036 997-8747/? D/ACDB-LOADER: ACDB -> ACDB_CMD_GET_AFE_COMMON_TABLE_SIZE
2020-11-15 13:59:37.036 997-8747/? D/ACDB-LOADER: ACDB -> ACDB_CMD_GET_AFE_COMMON_TABLE
2020-11-15 13:59:37.036 997-8747/? D/ACDB-LOADER: ACDB -> AUDIO_SET_AFE_CAL
2020-11-15 13:59:37.036 997-8747/? D/ACDB-LOADER: ACDB -> send_hw_delay : acdb_id = 513 path = 0
2020-11-15 13:59:37.036 997-8747/? D/ACDB-LOADER: ACDB -> ACDB_AVSYNC_INFO: ACDB_CMD_GET_DEVICE_PROPERTY
2020-11-15 13:59:37.036 997-8747/? D/audio_hw_primary: enable_audio_route: usecase(1) apply and update mixer path: low-latency-playback speaker
2020-11-15 13:59:37.036 997-8747/? D/audio_route: Apply path: low-latency-playback speaker
2020-11-15 13:59:37.044 15188-15188/? W/CAM_CaptureActivity: Package a.b.c.droid doesn't have location permissions, location info won't be included in EXIF
2020-11-15 13:59:37.052 1015-1094/? I/VSC: @ 75988.802: {Fusion} configure fusion 11 200000us 0us.
2020-11-15 13:59:37.052 1015-1094/? D/VSC: @ 75988.802: [Rotation Vector Sensor] Request accel, interval 200.0 ms, latency 0.0 ms
2020-11-15 13:59:37.057 1015-1094/? D/VSC: @ 75988.803: [Rotation Vector Sensor] Request gyro, interval 5.0 ms, latency 0.0 ms
2020-11-15 13:59:37.057 1015-1094/? D/VSC: @ 75988.803: [Rotation Vector Sensor] Request mag, interval 20.0 ms, latency 0.0 ms
2020-11-15 13:59:37.057 1015-1094/? D/ASH: @ 75988.807: SensorType 1 resampler quality 1
**2020-11-15 13:59:37.085 15188-15188/? W/CAM_ActivityUiStartup: CameraActivityController failed!
java.lang.IllegalStateException: GCA not granted write permission to content://a.b.c.mediastore/image/1/IMG_1_20201115_1359369962534309292671831.jpg, the specified output in intent: Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=com.google.android.GoogleCamera/com.android.camera.activity.CaptureActivity clip={text/uri-list {...}} (has extras) }.
at oqb.b(PG:40)**
at bes.a(PG:26)
at ekq.<init>(PG:2)
at ekr.a(PG:5)
at elj.get(PG:5)
at qjq.get(PG:3)
at fnn.a(PG:3)
at eeh.b(PG:362)
at eeh.r(PG:149)
at bjd.b(PG:6)
at bjd.a(PG:9)
at bso.run(Unknown Source:1)
at bnw.run(Unknown Source:6)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
2020-11-15 13:59:37.085 15188-15215/? W/CAM_ActivityUiStartup: Interactivity failed!
java.lang.IllegalStateException: GCA not granted write permission to content://a.b.c.mediastore/image/1/IMG_1_20201115_1359369962534309292671831.jpg, the specified output in intent: Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=com.google.android.GoogleCamera/com.android.camera.activity.CaptureActivity clip={text/uri-list {...}} (has extras) }.
at oqb.b(PG:40)
at bes.a(PG:26)
at ekq.<init>(PG:2)
at ekr.a(PG:5)
at elj.get(PG:5)
at qjq.get(PG:3)
at fnn.a(PG:3)
at eeh.b(PG:362)
at eeh.r(PG:149)
at bjd.b(PG:6)
at bjd.a(PG:9)
at bso.run(Unknown Source:1)
at bnw.run(Unknown Source:6)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
2020-11-15 13:59:37.087 15188-15188/? D/AndroidRuntime: Shutting down VM
2020-11-15 13:59:37.087 997-8747/? D/audio_hw_primary: out_write: retry previous failed cal level set
--------- beginning of crash
2020-11-15 13:59:37.088 15188-15188/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.google.android.GoogleCamera, PID: 15188
java.lang.RuntimeException: java.lang.IllegalStateException: GCA not granted write permission to content://a.b.c.mediastore/image/1/IMG_1_20201115_1359369962534309292671831.jpg, the specified output in intent: Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=com.google.android.GoogleCamera/com.android.camera.activity.CaptureActivity clip={text/uri-list {...}} (has extras) }.
at lrn.run(PG:2)
at bnw.run(Unknown Source:6)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.IllegalStateException: GCA not granted write permission to content://a.b.c.mediastore/image/1/IMG_1_20201115_1359369962534309292671831.jpg, the specified output in intent: Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=com.google.android.GoogleCamera/com.android.camera.activity.CaptureActivity clip={text/uri-list {...}} (has extras) }.
at oqb.b(PG:40)
at bes.a(PG:26)
at ekq.<init>(PG:2)
at ekr.a(PG:5)
at elj.get(PG:5)
at qjq.get(PG:3)
at fnn.a(PG:3)
at eeh.b(PG:362)
at eeh.r(PG:149)
at bjd.b(PG:6)
at bjd.a(PG:9)
at bso.run(Unknown Source:1)
at bnw.run(Unknown Source:6)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
2020-11-15 13:59:37.088 1015-1094/? I/VSC: @ 75988.838: [DoubleTwist] doubleTwistPower 1
2020-11-15 13:59:37.088 1015-1094/? D/VSC: @ 75988.838: [Double Twist] Request motion_detect, interval 18446744027136.0 ms, latency 0.0 ms
2020-11-15 13:59:37.091 1551-6352/? D/CompatibilityChangeReporter: Compat change id reported: 135634846; UID 10171; state: DISABLED
2020-11-15 13:59:37.092 1551-1665/? D/CompatibilityChangeReporter: Compat change id reported: 143937733; UID 10171; state: ENABLED
2020-11-15 13:59:37.092 15188-15188/? W/CAM_ShotTracker: Uncaught exception. Annotating all active shots.
2020-11-15 13:59:37.096 1551-18970/? I/DropBoxManagerService: add tag=system_app_crash isTagEnabled=true flags=0x2
2020-11-15 13:59:37.097 1551-6352/? W/ActivityTaskManager: Force finishing activity com.google.android.GoogleCamera/com.android.camera.activity.CaptureActivity
2020-11-15 13:59:37.100 985-985/? D/Zygote: Forked child process 18971
2020-11-15 13:59:37.102 1551-15562/? E/libc: Access denied finding property "vendor.debug.egl.changepixelformat"
2020-11-15 13:59:37.108 1551-15562/? E/libc: Access denied finding property "vendor.debug.egl.swapinterval"
2020-11-15 13:59:37.109 1551-15562/? E/FrameEvents: updateAcquireFence: Did not find frame.
2020-11-15 13:59:37.110 18971-18971/? E/ra:crash_repor: Not starting debugger since process cannot load the jdwp agent.
2020-11-15 13:59:37.100 1551-6352/? W/ActivityTaskManager: Force finishing activity com.google.android.GoogleCamera/com.android.camera.activity.CaptureActivity
2020-11-15 13:59:37.112 1551-6352/? W/ActivityTaskManager: Force finishing activity a.b.c.droid/a.b.c.activity.MessageCompose
2020-11-15 13:59:37.114 1551-1664/? W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.stats.service.DropBoxEntryAddedReceiver
2020-11-15 13:59:37.114 1551-1664/? W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver
2020-11-15 13:59:37.116 1551-1665/? I/ActivityManager: Start proc 18971:com.google.android.GoogleCamera:crash_report/u0a171 for service {com.google.android.GoogleCamera/com.google.android.apps.camera.app.silentfeedback.SilentFeedbackService}
2020-11-15 13:59:37.117 1551-1658/? D/EventSequenceValidator: Transition from ACTIVITY_LAUNCHED to ACTIVITY_CANCELLED
2020-11-15 13:59:37.120 15188-15188/? I/Process: Sending signal. PID: 15188 SIG: 9
2020-11-15 13:59:37.129 1551-3633/? D/CompatibilityChangeReporter: Compat change id reported: 136274596; UID 10171; state: ENABLED
2020-11-15 13:59:37.138 18971-18971/? I/ra:crash_repor: The ClassLoaderContext is a special shared library.
2020-11-15 13:59:37.140 18971-18971/? D/nativeloader: classloader namespace configured for unbundled vendor apk. library_path=/data/app/~~1nPVuzYmg7wcx5L3dD4WiA==/com.google.android.GoogleCamera-Ahx8lap9A8BQ9s3M0bcP8g==/lib/arm64:/data/app/~~1nPVuzYmg7wcx5L3dD4WiA==/com.google.android.GoogleCamera-Ahx8lap9A8BQ9s3M0bcP8g==/base.apk!/lib/arm64-v8a:/vendor/lib64
2020-11-15 13:59:37.146 18971-18971/? W/ra:crash_repor: Insufficient pre-allocated space to mmap vdex.
2020-11-15 13:59:37.156 18971-18971/? D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2020-11-15 13:59:37.156 18971-18971/? D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2020-11-15 13:59:37.165 1228-1404/? D/BufferPoolAccessor2.0: bufferpool2 0x6ff97c7508 : 0(0 size) total buffers - 0(0 size) used buffers - 14/18 (recycle/alloc) - 4/17 (fetch/transfer)
2020-11-15 13:59:37.165 1228-2651/? D/BufferPoolAccessor2.0: bufferpool2 0x6ff97cc158 : 0(0 size) total buffers - 0(0 size) used buffers - 21/27 (recycle/alloc) - 6/26 (fetch/transfer)
2020-11-15 13:59:37.165 1228-1404/? D/BufferPoolAccessor2.0: Destruction - bufferpool2 0x6ff97c7508 cached: 0/0M, 0/0% in use; allocs: 18, 78% recycled; transfers: 17, 76% unfetched
2020-11-15 13:59:37.166 1228-2651/? D/BufferPoolAccessor2.0: Destruction - bufferpool2 0x6ff97cc158 cached: 0/0M, 0/0% in use; allocs: 27, 78% recycled; transfers: 26, 77% unfetched
2020-11-15 13:59:37.166 1228-2651/? D/BufferPoolAccessor2.0: bufferpool2 0x6ff97cd188 : 0(0 size) total buffers - 0(0 size) used buffers - 10/14 (recycle/alloc) - 4/13 (fetch/transfer)
2020-11-15 13:59:37.166 1228-2651/? D/BufferPoolAccessor2.0: Destruction - bufferpool2 0x6ff97cd188 cached: 0/0M, 0/0% in use; allocs: 14, 71% recycled; transfers: 13, 69% unfetched
2020-11-15 13:59:37.166 985-985/? I/Zygote: Process 15188 exited due to signal 9 (Killed)