Null parameter transfer on Android interface causes Unity to stop responding (ANR)
What is ANR
-
When your activity is in the foreground, your application does not respond to input events or BroadcastReceiver (such as key press or screen tap events) within 5 seconds. -
Although there is no activity in the foreground, your BroadcastReceiver has not been executed for a long time.
discover problems
E CrashReport: ANR in com.xxxx(com.xxxx/com.xxxx.launcher) 11-25 14:58:57.939 22468 22530 E CrashReport: PID: 22468 11-25 14:58:57.939 22468 22530 E CrashReport: Reason: Input dispatching timed out (Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up.)
11-25 14:58:44.444 22468 22468 E CRASH : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00002458 11-25 14:58:44.444 22468 22468 E CRASH : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 11-25 14:58:44.444 22468 22468 E CRASH : Build type 'Release', Scripting Backend 'mono', CPU 'armeabi-v7a' 11-25 14:58:44.444 22468 22468 E CRASH : Build fingerprint: 'xxxxxxxxxxxxxxxx' 11-25 14:58:44.445 22468 22468 E CRASH : Revision: '0' 11-25 14:58:44.445 22468 22468 E CRASH : pid: 22468, tid: 22468, name: r.com.xxxx >>> com.xxxx <<< 11-25 14:58:44.445 22468 22468 E CRASH : r0 00000000 r1 00002458 r2 00000000 r3 80000000 11-25 14:58:44.445 22468 22468 E CRASH : r4 00000000 r5 fff18810 r6 fff18810 r7 fff18d10 11-25 14:58:44.445 22468 22468 E CRASH : r8 cddd0690 r9 cddd069c sl fff18930 fp cddd0698 11-25 14:58:44.445 22468 22468 E CRASH : ip ca6636a8 sp fff18808 lr c9dcd8f8 pc c9820e94 cpsr 000057c4 11-25 14:58:44.445 22468 22468 E CRASH : 11-25 14:58:44.445 22468 22468 E CRASH : backtrace: 11-25 14:58:44.452 22468 22468 E CRASH : #00 pc 0029ae94 /data/app/com/xxxx/lib/arm/libunity.so
//Declare an interface for Unity inheritance implementation package com.azimiao.test; public interface SomeListenerCallback{ void onSomethingHappen(String msg); }
//Inherit and implement Android interface in Unity public class SomeListenerCallback : AndroidJavaProxy { public SomeListenerCallback():base("com.azimiao.test.SomeListenerCallback") { } public void onSomethingHappen(string msg) { Debug. Log("DoSomething:" + (msg ?? "")); //other } }
someListenerCallbackInstance.onSomethingHappen(msg);
Causes
resolvent
Comment
Comment area
0F Hello~I am the operator of Tencent Cloud+Community, and I have followed the technical articles you are sharing. I think the content is great. We sincerely invite you to join the Tencent Cloud We Media Sharing Program. For complete benefits and application address, please see: [Blocked link] After the author applies for this plan, the author will move his articles to the community column. You just need to fill in the form to apply. We will provide the author with traffic, ECS, domain names, etc., as well as some peripheral gifts. We sincerely invite you and look forward to your joining~