运行大小超过 2GB 的 apk 文件时崩溃

Posted

技术标签:

【中文标题】运行大小超过 2GB 的 apk 文件时崩溃【英文标题】:Crash when run apk file with size over 2GB 【发布时间】:2021-03-19 10:41:38 【问题描述】:

当我在本地安装 APK 游戏(由 cocos2d-x 构建)(通过 USB 复制)且资源超过 2GB 时,检查日志 adb 有错误,google play store 弹出一直停止,我无法运行我的 apk:

A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 16853 (BlockingExecuto), pid 12159 (android.vending) 
E/crash_dump32: unknown process state: t 
A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 
A/DEBUG: Build fingerprint: 'samsung/beyond2ltexx/beyond2:10/QP1A.190711.020/G975FXXU9DTJA:user/release-keys' 
A/DEBUG: Revision: '26' 
A/DEBUG: ABI: 'arm' 
A/DEBUG: Timestamp: 
2020-12-08 11:56:49+0700 
A/DEBUG: pid: 12159, tid: 16853, name: BlockingExecuto >>> com.android.vending <<< 
A/DEBUG: uid: 10109 
A/DEBUG: signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr -------- 
A/DEBUG: Abort message: 'ubsan: implicit-conversion' 
A/DEBUG: r0 00000000 r1 000041d5 r2 00000006 r3 c479f180 
A/DEBUG: r4 c479f194 r5 c479f178 r6 00002f7f r7 0000016b 
A/DEBUG: r8 c479f190 r9 c479f180 r10 c479f1b0 r11 c479f1a0 
A/DEBUG: ip 000041d5 sp c479f150 lr f58893b7 pc f58893ca 
A/DEBUG: backtrace: 
A/DEBUG: #00 pc 000603ca /apex/com.android.runtime/lib/bionic/libc.so (abort+166) (BuildId: 51d80220c9e0c42255369657a8641799) 
A/DEBUG: #01 pc 000118d4 /system/lib/libutils.so (abort_with_message(char const*)+24) (BuildId: da88f99cb4c80fe4fe393ef8e8fd5c71) 
A/DEBUG: #02 pc 000119cc /system/lib/libutils.so (__ubsan_handle_implicit_conversion_minimal_abort+24) (BuildId: da88f99cb4c80fe4fe393ef8e8fd5c71) 
A/DEBUG: #03 pc 0000a1f9 /system/lib/libutils.so (android::FileMap::create(char const*, int, long long, unsigned int, bool)+336) (BuildId: da88f99cb4c80fe4fe393ef8e8fd5c71) 
A/DEBUG: #04 pc 00021cd5 /system/lib/libandroidfw.so (android::ApkAssets::Open(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator> const&, android::Asset::AccessMode) const+236) (BuildId: c2985fc4fb507640b2e6e08af143b74f) 
A/DEBUG: #05 pc 0002124f /system/lib/libandroidfw.so (android::ApkAssets::LoadImpl(android::base::unique_fd_implandroid::base::DefaultCloser, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator> const&, std::__1::unique_ptr<android::Asset, std::__1::default_deleteandroid::Asset>, std::__1::unique_ptr<android::LoadedIdmap const, std::__1::default_delete<android::LoadedIdmap const>>, bool, bool)+390) (BuildId: c2985fc4fb507640b2e6e08af143b74f) 
A/DEBUG: #06 pc 00021069 /system/lib/libandroidfw.so (android::ApkAssets::Load(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator> const&, bool)+40) (BuildId: c2985fc4fb507640b2e6e08af143b74f) 
A/DEBUG: #07 pc 0014914b /system/lib/libandroid_runtime.so (android::NativeLoad(_JNIEnv*, _jclass*, _jstring*, unsigned char, unsigned char, unsigned char)+442) (BuildId: 80997d838eed4d8a33e6074aaefa721e) 
A/DEBUG: #08 pc 002e8ae9 /system/framework/arm/boot-framework.oat (art_jni_trampoline+136) (BuildId: 08d023656c5c190cd87e02dca8cd73789c24a32e) 
A/DEBUG: #09 pc 00442c2b /system/framework/arm/boot-framework.oat (android.content.pm.PackageParser.parseApkLiteInner+250) (BuildId: 08d023656c5c190cd87e02dca8cd73789c24a32e) 
A/DEBUG: #10 pc 0044ad41 /system/framework/arm/boot-framework.oat (android.content.pm.PackageParser.parseMonolithicPackageLite+96) (BuildId: 08d023656c5c190cd87e02dca8cd73789c24a32e) 
A/DEBUG: #11 pc 00450d17 /system/framework/arm/boot-framework.oat (android.content.pm.PackageParser.parseMonolithicPackage+70) (BuildId: 08d023656c5c190cd87e02dca8cd73789c24a32e) 
A/DEBUG: #12 pc 00439495 /system/framework/arm/boot-framework.oat (android.content.pm.PackageManager.getPackageArchiveInfo+196) (BuildId: 08d023656c5c190cd87e02dca8cd73789c24a32e) 
A/DEBUG: #13 pc 00eeaa41 /data/app/com.android.vending-9uL9ZPy1nPnI_iSyOwpVqw==/oat/arm/base.odex (com.google.android.finsky.verifier.impl.VerifyInstallTask.j+328) 
A/DEBUG: #14 pc 000d7bc5 /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub_internal+68) (BuildId: 4f8c69e84af2316a61452c2d70d699f2) 
A/DEBUG: #15 pc 0042e22b /apex/com.android.runtime/lib/libart.so (art_quick_invoke_static_stub+246) (BuildId: 4f8c69e84af2316a61452c2d70d699f2) 
A/DEBUG: #16 pc 000dffcb /apex/com.android.runtime/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+194) (BuildId: 4f8c69e84af2316a61452c2d70d699f2) 
A/DEBUG: #17 pc 00210141 /apex/com.android.runtime/lib/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+280) (BuildId: 4f8c69e84af2316a61452c2d70d699f2) 
A/DEBUG: #18 pc 0020ba83 /apex/com.android.runtime/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+774) (BuildId: 4f8c69e84af2316a61452c2d70d699f2) 
A/DEBUG: #19 pc 00425947 /apex/com.android.runtime/lib/libart.so (MterpInvokeStatic+310) (BuildId: 4f8c69e84af2316a61452c2d70d699f2) 
A/DEBUG: #20 pc 000d2994 /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_static+20) (BuildId: 4f8c69e84af2316a61452c2d70d699f2) 
A/DEBUG: #21 pc 0112a122 /data/app/com.android.vending-9uL9ZPy1nPnI_iSyOwpVqw==/oat/arm/base.vdex (com.google.android.finsky.verifier.impl.VerifyAppsInstallTask.Z+62) 
A/DEBUG: #22 pc 004254a9 /apex/com.android.runtime/lib/libart.so (MterpInvokeDirect+980) (BuildId: 4f8c69e84af2316a61452c2d70d699f2) 
A/DEBUG: #23 pc 000d2914 /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_direct+20) (BuildId: 4f8c69e84af2316a61452c2d70d699f2) 
A/DEBUG: #24 pc 0112ae72 /data/app/com.android.vending-9uL9ZPy1nPnI_iSyOwpVqw==/oat/arm/base.vdex (com.google.android.finsky.verifier.impl.VerifyAppsInstallTask.mH+1588) 
A/DEBUG: #25 pc 00428b03 /apex/com.android.runtime/lib/libart.so (MterpInvokeVirtualQuick+1118) (BuildId: 4f8c69e84af2316a61452c2d70d699f2) 
A/DEBUG: #26 pc 000d6594 /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_virtual_quick+20) (BuildId: 4f8c69e84af2316a61452c2d70d699f2) 
A/DEBUG: #27 pc 0112ba8a /data/app/com.android.vending-9uL9ZPy1nPnI_iSyOwpVqw==/oat/arm/base.vdex (com.google.android.finsky.verifier.impl.VerifyInstallTask.mH+82) 
A/DEBUG: #28 pc 001eb9bd /apex/com.android.runtime/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEbb.llvm.14245495856725529891+192) (BuildId: 4f8c69e84af2316a61452c2d70d699f2) 
A/DEBUG: #29 pc 001f01a1 /apex/com.android.runtime/lib/libart.so (art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*)+124) (BuildId: 4f8c69e84af2316a61452c2d70d699f2) 
A/DEBUG: #30 pc 00417c89 /apex/com.android.runtime/lib/libart.so (artQuickToInterpreterBridge+808) (BuildId: 4f8c69e84af2316a61452c2d70d699f2) 
A/DEBUG: #31 pc 000dc5a1 /apex/com.android.runtime/lib/libart.so (art_quick_to_interpreter_bridge+32) (BuildId: 4f8c69e84af2316a61452c2d70d699f2) 
A/DEBUG: #32 pc 0061b5a3 /data/app/com.android.vending-9uL9ZPy1nPnI_iSyOwpVqw==/oat/arm/base.odex (amgs.run+58) 
A/DEBUG: #33 pc 002a8fcf /system/framework/arm/boot.oat (java.util.concurrent.ThreadPoolExecutor.runWorker+1014) (BuildId: 583c1081e85d9d8b674ee07cd01998bc18f28442) 
A/DEBUG: #34 pc 002a6c4f /system/framework/arm/boot.oat (java.util.concurrent.ThreadPoolExecutor$Worker.run+54) (BuildId: 583c1081e85d9d8b674ee07cd01998bc18f28442) 
A/DEBUG: #35 pc 005dad1f /data/app/com.android.vending-9uL9ZPy1nPnI_iSyOwpVqw==/oat/arm/base.odex (akoy.run+78) 
A/DEBUG: #36 pc 00183749 /system/framework/arm/boot.oat (java.lang.Thread.run+64) (BuildId: 583c1081e85d9d8b674ee07cd01998bc18f28442) 
A/DEBUG: #37 pc 000d7bc5 /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub_internal+68) (BuildId: 4f8c69e84af2316a61452c2d70d699f2) 
A/DEBUG: #38 pc 0042e117 /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub+250) (BuildId: 4f8c69e84af2316a61452c2d70d699f2) 
A/DEBUG: #39 pc 000dffb7 /apex/com.android.runtime/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+174) (BuildId: 4f8c69e84af2316a61452c2d70d699f2) 
A/DEBUG: #40 pc 0036fc27 /apex/com.android.runtime/lib/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+54) (BuildId: 4f8c69e84af2316a61452c2d70d699f2) 
A/DEBUG: #41 pc 00370919 /apex/com.android.runtime/lib/libart.so (art::InvokeVirtualOrInterfaceWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, jvalue const*)+304) (BuildId: 4f8c69e84af2316a61452c2d70d699f2) 
A/DEBUG: #42 pc 003a18a7 /apex/com.android.runtime/lib/libart.so (art::Thread::CreateCallback(void*)+978) (BuildId: 4f8c69e84af2316a61452c2d70d699f2) 
A/DEBUG: #43 pc 000a75b3 /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*)+20) (BuildId: 51d80220c9e0c42255369657a8641799) 
A/DEBUG: #44 pc 00061b33 /apex/com.android.runtime/lib/bionic/libc.so (__start_thread+30) (BuildId: 51d80220c9e0c42255369657a8641799) 
E//system/bin/tombstoned: Tombstone written to: /data/tombstones/tombstone_01 

如果我减少的资源少于 2GB,我可以正常运行应用程序。任何人都可以帮助我,请?

【问题讨论】:

【参考方案1】:

正如您的日志所暗示的,问题在于函数android::FileMap::create() 其中 off64_t 类型用于调用 mmap(),而应该调用 mmap64()

从那时起,它已被 Google 修复 (commit),但不幸的是,它直到 Android R 才会部署,正如 google 问题跟踪器中的 thread 中所述。

同时最好的办法是保持在 2Go 限制以下,这样 off64_t 值就不会触发 UBSan: 隐式转换,从而导致您的应用崩溃。

【讨论】:

以上是关于运行大小超过 2GB 的 apk 文件时崩溃的主要内容,如果未能解决你的问题,请参考以下文章

如何在 Ada 中读取大文件?

应用程序作为 APK 运行,但通过 Play 商店发布时崩溃

iOS 应用程序的最大大小

部署apk时Android Studio ..Application崩溃[重复]

发布 apk 安装但启动时崩溃。该应用程序在调试模式下完美运行。我查看了 Android Studio,这是我的 adb logcat。

ADO 查询导致 mdb 数据库超过 2GB 限制