最近打包到安卓測試時進logo后一直閃退,打開Android Logcat后發(fā)現(xiàn)拋出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)
看樣子是空引用崩潰的
在網(wǎng)上找了幾個方法來試試,到最后才發(fā)現(xiàn)是場景里有Missing物體
方法1.關(guān)閉StripEngineCode
在Project Settings選擇Player頁,在里面的Other Settings取消勾選Strip Engine Code
我試了這個對我沒用,但是其他人反饋確實有用
方法2.更新Burst和Job包
在Package Manager里搜索Burst和Job(Job可能需要打開Package Manager里的Enable Pre-release Packages選項才看得到)總之就是要更新ECS依賴的包
當(dāng)然我的工程里沒用這兩個包,所以不用更新文章來源:http://www.zghlxwxcb.cn/news/detail-840816.html
解決辦法:
在需要打開的場景查看console窗口是否有這種錯誤提示,然后把場景內(nèi)提示的Prefab(刪除Hierarchy里帶紅色名字的物體)刪除過后打包安卓測試即沒有 null pointer dereference 的錯誤拋出
場景不清理,崩潰兩行淚啊文章來源地址http://www.zghlxwxcb.cn/news/detail-840816.html
到了這里,關(guān)于Unity IL2CPP包Crash閃退提示 Cause: null pointer dereference 解決辦法的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!