If you want better answers I think you need to give more details eg: Mono runtime or il2cpp? What’s the crash? what’s the call stack look like for the crash? Is the above test code reproducing the actual case you care about (referencing a null pointer?)? What version of Unity?
Unity 2017.1.1f1, Mono,Net 4.5.But android device monitor is not loging this crash.How to get more information about call stack ?This situation only on Null Exception(I suspect)
Hi, I actually got the same issue with Unity 2017.1.2f1. Try Catch - Block works fine in Editor but on Android it didn’t “catch” the error and just collapse the app.
I am having the exact same problem.
NullReferenceException on Android build will always crash the app and quit, even inside try-catch. On editor is logging correctly (and not crashing).
This erros occurs on any 2017.x Unity version. On Unity 5.6 works fine.
Using IL2CPP the crash does not occur. I don’t know why this happens only using Mono.
I don’t know how to force this problem, because this is happening only in one of my projects. I tried do delete Library and ProjectSettings folders to start over, but the problem still persists.
Hello : )
I ran your example code using Unity 2017.3.1f1 Mono 3.5 and Mono 4.6 on Razer Phone (OS 7.1.1) and did not get a crash.
Would appreciate a repro project, version list and device list you can repro this on : )
using UnityEngine;
public class Catcher : MonoBehaviour
{
void Awake()
{
CustomClass myClass = null;
try
{
myClass.func();
}
catch
{
Debug.Log("Exception caught successfully!");
}
}
}
public class CustomClass
{
public void func()
{
Debug.Log("Good init");
}
}
We have the exact same problem in Unity 2017.2.1p4 with .net 3.5. Null reference exceptions cause a native crash!
Tested on Samsung galaxy s7, nexus 7 so far…
This only happens on android.(and it has never been this way before)
Tested both with stripping enabled and disabled.
mono as backend causes the crash both with .net 3.5 and 4.6
As a follow up, I’ve now tested this in Unity 2017.3.0 and Unity 2017.3.1 both are ok and don’t contain this issue.
So for anybody that finds this, should know that launching a game on Android with Unity 2017.2.x using Mono as backend is currently completely broken.
Null reference exceptions cause native crashes on android with no way to protect against it! Edit: NOT Fixed by update to 2017.3.x or using il2cpp as backend.