Parcel android.os.Parcel@439e4cf0

本文探讨了在Android应用中使用Parcel传递复杂数据结构时出现的崩溃问题。具体表现为因数据读取顺序不一致导致部分设备上应用闪退。文章详细解释了问题原因,并提供了正确的数据读写顺序示例来确保数据的一致性和应用程序的稳定性。

https://www.3566t.com/news/show-5683902.html



项目的报错

:Unable to start activity ComponentInfo{com.jindaozi.app/com.jindaozi.app.activity.financ.SubmitPayActivity}: 
java.lang.RuntimeException: Parcel android.os.Parcel@439e4cf0: Unmarshalling unknown type code 7471216 at offset 292


原因:在传递parcel传递数据时候,数据的读取顺序没有一致,部分手机会出现闪退现象


解决方法:读取的顺序应该一致

 /**
     * 这里的读的顺序必须与writeToParcel(Parcel dest, int flags)方法中
     * 写的顺序一致,否则数据会有差错,比如你的读取顺序如果是:
     * nickname = source.readString();
     * username=source.readString();
     * age = source.readInt();
     * 即调换了username和nickname的读取顺序,那么你会发现你拿到的username是nickname的数据,
     * 而你拿到的nickname是username的数据
     * @param source
     */
    public Person(Parcel source) {
        username = source.readString();
        nickname=source.readString();
        age = source.readInt();
    }
    /**
     * 把值写入Parcel中
     */
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(username);
        dest.writeString(nickname);
        dest.writeInt(age);
    }




11-06 11:31:19.384798 2568 2728 F libc : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 2728 (binder:2568_3), pid 2568 (droid.bluetooth) 11-06 11:31:39.360696 4166 4166 F DEBUG : Process name is com.android.bluetooth, uid is 1002, not key_process 11-06 11:31:39.360808 4166 4166 F DEBUG : keyProcess: 0 11-06 11:31:39.360835 4166 4166 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 11-06 11:31:39.360859 4166 4166 F DEBUG : Build fingerprint: 'realme/RMX5170/RE6411L1:16/BP2A.250605.015/B.498e7da-28e171f-28f0d1e:user/release-keys' 11-06 11:31:39.360877 4166 4166 F DEBUG : Revision: '0' 11-06 11:31:39.362143 4166 4166 F DEBUG : ABI: 'arm64' 11-06 11:31:39.362266 4166 4166 F DEBUG : Timestamp: 2025-11-06 11:31:30.091866802+0800 11-06 11:31:39.362300 4166 4166 F DEBUG : Process uptime: 0s 11-06 11:31:39.362321 4166 4166 F DEBUG : Cmdline: com.android.bluetooth 11-06 11:31:39.362340 4166 4166 F DEBUG : pid: 2568, tid: 2728, name: binder:2568_3 >>> com.android.bluetooth <<< 11-06 11:31:39.362357 4166 4166 F DEBUG : uid: 1002 11-06 11:31:39.362379 4166 4166 F DEBUG : tagged_addr_ctrl: 0000000000000001 (PR_TAGGED_ADDR_ENABLE) 11-06 11:31:39.362400 4166 4166 F DEBUG : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr -------- 11-06 11:31:39.362422 4166 4166 F DEBUG : Abort message: '[dumpsys.cc:70] Dump: Timed out waiting for dumpsys to complete' 11-06 11:31:39.362461 4166 4166 F DEBUG : x0 0000000000000000 x1 0000000000000aa8 x2 0000000000000006 x3 0000007880bafaf0 11-06 11:31:39.362485 4166 4166 F DEBUG : x4 1f73746e1f63646c x5 1f73746e1f63646c x6 1f73746e1f63646c x7 7f7f7f7f7f7f7f7f 11-06 11:31:39.362507 4166 4166 F DEBUG : x8 00000000000000f0 x9 6feb1b86c2fff7c0 x10 0000000000000001 x11 00000079de0c14e0 11-06 11:31:39.362529 4166 4166 F DEBUG : x12 b4000078e06b3540 x13 0000007880bafe39 x14 0000000000000001 x15 00000000ffffffa5 11-06 11:31:39.362563 4166 4166 F DEBUG : x16 00000079de132828 x17 00000079de116580 x18 00000077fab14030 x19 0000000000000a08 11-06 11:31:39.362587 4166 4166 F DEBUG : x20 0000000000000aa8 x21 00000000ffffffff x22 000000000000003f x23 0000007880bafc31 11-06 11:31:39.362613 4166 4166 F DEBUG : x24 0000000000000040 x25 00000077f1a6ba08 x26 0000000000000005 x27 0000007880bb2880 11-06 11:31:39.362637 4166 4166 F DEBUG : x28 00000077f1a6bcc0 x29 0000007880bafb70 11-06 11:31:39.362658 4166 4166 F DEBUG : lr 00000079de0aa6e8 sp 0000007880bafaf0 pc 00000079de0aa70c pst 0000000000001000 11-06 11:31:39.362687 4166 4166 F DEBUG : 33 total frames 11-06 11:31:39.362703 4166 4166 F DEBUG : backtrace: 11-06 11:31:39.362730 4166 4166 F DEBUG : #00 pc 000000000008b70c /apex/com.android.runtime/lib64/bionic/libc.so (abort+156) (BuildId: 65b0c8857610bf85fb81a624be775cc4) 11-06 11:31:39.362755 4166 4166 F DEBUG : #01 pc 00000000004a38d4 /system/lib64/libbluetooth_jni.so (LogReceive::LogRecorder::~LogRecorder()+3796) (BuildId: 5ffaa40b8de162ccbd4d3f029fc50f2a) 11-06 11:31:39.362782 4166 4166 F DEBUG : #02 pc 00000000004a4df8 /system/lib64/libbluetooth_jni.so (bluetooth::log_internal::oplus_vlog(bluetooth::log_internal::Level, char const*, bluetooth::log_internal::source_location const&, fmt::v11::basic_string_view<char>, fmt::v11::basic_format_args<fmt::v11::context>)+776) (BuildId: 5ffaa40b8de162ccbd4d3f029fc50f2a) 11-06 11:31:39.362809 4166 4166 F DEBUG : #03 pc 0000000000f1e5e4 /system/lib64/libbluetooth_jni.so (bluetooth::log_internal::vlog(bluetooth::log_internal::Level, char const*, bluetooth::log_internal::source_location, fmt::v11::basic_string_view<char>, fmt::v11::basic_format_args<fmt::v11::context>)+372) (BuildId: 5ffaa40b8de162ccbd4d3f029fc50f2a) 11-06 11:31:39.362865 4166 4166 F DEBUG : #04 pc 00000000004fac24 /system/lib64/libbluetooth_jni.so (bluetooth::shim::Dump(int, char const**)+452) (BuildId: 5ffaa40b8de162ccbd4d3f029fc50f2a) 11-06 11:31:39.362889 4166 4166 F DEBUG : #05 pc 00000000009699d0 /system/lib64/libbluetooth_jni.so (dump(int, char const**)+336) (BuildId: 5ffaa40b8de162ccbd4d3f029fc50f2a) 11-06 11:31:39.362915 4166 4166 F DEBUG : #06 pc 000000000043a7dc /system/lib64/libbluetooth_jni.so (android::dumpNative(_JNIEnv*, _jobject*, _jobject*, _jobjectArray*)+396) (BuildId: 5ffaa40b8de162ccbd4d3f029fc50f2a) 11-06 11:31:39.362938 4166 4166 F DEBUG : #07 pc 00000000003a601c /system/framework/arm64/boot.oat (art_jni_trampoline+140) (BuildId: f0a6980f9e85d05cf796ef2de1d124a8a02b27e1) 11-06 11:31:39.362960 4166 4166 F DEBUG : #08 pc 000000000085d220 /apex/com.android.art/lib64/libart.so (nterp_helper+4016) (BuildId: 4f608fc101f00286ba9411364fdeaab9) 11-06 11:31:39.362982 4166 4166 F DEBUG : #09 pc 00000000002f2da0 /system/app/Bluetooth/Bluetooth.apk (offset 0x1000) (com.android.bluetooth.btservice.AdapterNativeInterface.dump+0) 11-06 11:31:39.363005 4166 4166 F DEBUG : #10 pc 000000000085d1c4 /apex/com.android.art/lib64/libart.so (nterp_helper+3924) (BuildId: 4f608fc101f00286ba9411364fdeaab9) 11-06 11:31:39.363027 4166 4166 F DEBUG : #11 pc 00000000002ffada /system/app/Bluetooth/Bluetooth.apk (offset 0x1000) (com.android.bluetooth.btservice.AdapterService.dump+570) 11-06 11:31:39.363048 4166 4166 F DEBUG : #12 pc 000000000085d1c4 /apex/com.android.art/lib64/libart.so (nterp_helper+3924) (BuildId: 4f608fc101f00286ba9411364fdeaab9) 11-06 11:31:39.363070 4166 4166 F DEBUG : #13 pc 00000000002f8f34 /system/app/Bluetooth/Bluetooth.apk (offset 0x1000) (com.android.bluetooth.btservice.AdapterService$AdapterServiceBinder.dump+40) 11-06 11:31:39.396613 4166 4166 F DEBUG : #14 pc 000000000070aef8 /system/framework/arm64/boot-framework.oat (android.os.Binder.onTransact+648) (BuildId: 0e19719b16ecd762524f865b604b850c4710a4ef) 11-06 11:31:39.396872 4166 4166 F DEBUG : #15 pc 000000000085d948 /apex/com.android.art/lib64/libart.so (nterp_helper+5848) (BuildId: 4f608fc101f00286ba9411364fdeaab9) 11-06 11:31:39.396958 4166 4166 F DEBUG : #16 pc 000000000038c95e /system/framework/framework.jar (offset 0x7000) (android.bluetooth.IBluetooth$Stub.onTransact+66) 11-06 11:31:39.396996 4166 4166 F DEBUG : #17 pc 00000000007096c0 /system/framework/arm64/boot-framework.oat (android.os.Binder.execTransactInternal+976) (BuildId: 0e19719b16ecd762524f865b604b850c4710a4ef) 11-06 11:31:39.397025 4166 4166 F DEBUG : #18 pc 0000000000709154 /system/framework/arm64/boot-framework.oat (android.os.Binder.execTransact+388) (BuildId: 0e19719b16ecd762524f865b604b850c4710a4ef) 11-06 11:31:39.397061 4166 4166 F DEBUG : #19 pc 00000000004c8794 /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+612) (BuildId: 4f608fc101f00286ba9411364fdeaab9) 11-06 11:31:39.397089 4166 4166 F DEBUG : #20 pc 00000000004c5b40 /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeVirtualOrInterfaceWithVarArgs<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, std::__va_list)+672) (BuildId: 4f608fc101f00286ba9411364fdeaab9) 11-06 11:31:39.397116 4166 4166 F DEBUG : #21 pc 000000000081c588 /apex/com.android.art/lib64/libart.so (art::JNI<false>::CallBooleanMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list)+200) (BuildId: 4f608fc101f00286ba9411364fdeaab9) 11-06 11:31:39.397141 4166 4166 F DEBUG : #22 pc 000000000011e388 /system/lib64/libandroid_runtime.so (_JNIEnv::CallBooleanMethod(_jobject*, _jmethodID*, ...)+120) (BuildId: f2734c931c4d99a4316065d95ebdf1c7) 11-06 11:31:39.397165 4166 4166 F DEBUG : #23 pc 00000000001f28b4 /system/lib64/libandroid_runtime.so (JavaBBinder::onTransact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+164) (BuildId: f2734c931c4d99a4316065d95ebdf1c7) 11-06 11:31:39.397189 4166 4166 F DEBUG : #24 pc 000000000004d910 /system/lib64/libbinder.so (android::BBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+320) (BuildId: 9eab5f4500f6156bca8298eab3c8594e) 11-06 11:31:39.397213 4166 4166 F DEBUG : #25 pc 000000000004e0b0 /system/lib64/libbinder.so (android::IPCThreadState::executeCommand(int)+1136) (BuildId: 9eab5f4500f6156bca8298eab3c8594e) 11-06 11:31:39.397246 4166 4166 F DEBUG : #26 pc 0000000000075f44 /system/lib64/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+452) (BuildId: 9eab5f4500f6156bca8298eab3c8594e) 11-06 11:31:39.397269 4166 4166 F DEBUG : #27 pc 0000000000075ae0 /system/lib64/libbinder.so (android::PoolThread::threadLoop()+96) (BuildId: 9eab5f4500f6156bca8298eab3c8594e) 11-06 11:31:39.397292 4166 4166 F DEBUG : #28 pc 0000000000019368 /system/lib64/libutils.so (android::Thread::_threadLoop(void*)+248) (BuildId: e41f2bc353059dc14cf4ee6b493447a4) 11-06 11:31:39.397315 4166 4166 F DEBUG : #29 pc 000000000013410c /system/lib64/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+140) (BuildId: f2734c931c4d99a4316065d95ebdf1c7) 11-06 11:31:39.397338 4166 4166 F DEBUG : #30 pc 000000000001bac4 /system/lib64/libutils.so (libutil_thread_trampoline(void*) (.__uniq.226528677032898775202282855395389835431)+20) (BuildId: e41f2bc353059dc14cf4ee6b493447a4) 11-06 11:31:39.397362 4166 4166 F DEBUG : #31 pc 000000000009c9b8 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+232) (BuildId: 65b0c8857610bf85fb81a624be775cc4) 11-06 11:31:39.397385 4166 4166 F DEBUG : #32 pc 000000000008ef10 /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: 65b0c8857610bf85fb81a624be775cc4)
最新发布
11-19
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值