最近打包到安卓测试时进logo后一直闪退,打开Android Logcat后发现抛出crash
0001/01/01 00:00:00.000 -1 -1 Info --------- beginning of crash
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime FATAL EXCEPTION: UnityMain
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime Process: 这是包名, PID: 2471
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime java.lang.Error: FATAL EXCEPTION [UnityMain]
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime Unity version : 2021.3.1f1
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime Device model : vivo V1938CT
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime Device fingerprint: google/android_x86/x86:7.1.2/N2G48C/4565141:user/release-keys
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime Build Type : Development
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime Scripting Backend : IL2CPP
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime ABI : armeabi-v7a
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime Strip Engine Code : true
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime Caused by: java.lang.Error: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime Version '2021.3.1f1 (3b70a0754835)', Build type 'Development', Scripting Backend 'il2cpp', CPU 'armeabi-v7a'
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime Build fingerprint: 'google/android_x86/x86:7.1.2/N2G48C/4565141:user/release-keys'
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime Revision: '0'
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime ABI: 'arm'
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime Timestamp: 2023-11-06 10:27:01+0800
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime pid: 2471, tid: 2489, name: UnityMain >>> 这是包名 <<<
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime uid: 10060
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x3c
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime Cause: null pointer dereference
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime r0 00000000 r1 050fe430 r2 89900950 r3 a1ba69ac
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime r4 89900950 r5 00000004 r6 8d3aac30 r7 a1ba69ac
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime r8 00000000 r9 89900abc r10 00000000 r11 00000000
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime ip 899196b0 sp a1ba6898 lr 045814c1 pc 0414d0d7
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime backtrace:
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime #00 pc 0014d0d7 /data/app/这是包名-1/lib/arm/libunity.so (GameObject::QueryComponentByType(Unity::Type const*) const+2) (BuildId: 71e6fc9bc8c2075465d91606de214c974fc923a6)
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime
2023/11/06 10:27:01.835 2471 2489 Error AndroidRuntime at libunity.GameObject::QueryComponentByType(Unity::Type const*) const(QueryComponentByType:2)
看样子是空引用崩溃的
在网上找了几个方法来试试,到最后才发现是场景里有Missing物体
方法1.关闭StripEngineCode
在Project Settings选择Player页,在里面的Other Settings取消勾选Strip Engine Code
我试了这个对我没用,但是其他人反馈确实有用
方法2.更新Burst和Job包
在Package Manager里搜索Burst和Job(Job可能需要打开Package Manager里的Enable Pre-release Packages选项才看得到)总之就是要更新ECS依赖的包
当然我的工程里没用这两个包,所以不用更新文章来源:https://www.toymoban.com/news/detail-840816.html
解决办法:
在需要打开的场景查看console窗口是否有这种错误提示,然后把场景内提示的Prefab(删除Hierarchy里带红色名字的物体)删除过后打包安卓测试即没有 null pointer dereference 的错误抛出
场景不清理,崩溃两行泪啊文章来源地址https://www.toymoban.com/news/detail-840816.html
到了这里,关于Unity IL2CPP包Crash闪退提示 Cause: null pointer dereference 解决办法的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!