Closed wangjianpeng closed 6 months ago
Exception java.lang.Error: FATAL EXCEPTION [Thread-331] Unity version : 2018.4.36f1 Device model : HMD Global Nokia G20 Device fingerprint: Nokia/Ronin_00EEA/RNN_sprout:13/TP1A.220624.014/00WW_3_31E:user/release-keys
Caused by: java.lang.NoSuchMethodError: no static method with name='Thread-331' signature='Thread-331' in class Ljava.lang.Object; at com.unity3d.player.ReflectionHelper.getMethodID
I also have this problem from Google background to crash users are basically 12 13 system
@ygslikewq1 Can you report this issue to the Android SDK Team?.
Include a link to this issue for reference.
@ygslikewq1 @wangjianpeng
Did you find something about this crash?
We're also facing this issue with 2020, android 12, 13, 14
@paradizIscool Can you report this issue to the Android SDK Team?.
Include a link to this issue for reference.
Did anyone reach a resolution on this? We are experiencing this despite not even having upgraded our Firebase version, which is strange.
Update for me -- these stack traces are apparently what can happen when code accesses Unity main-thread resources from off the main thread. We introduced the problem in our own code and resolved it by ensuring it did not access any Unity APIs unless dispatched to the main thread (e.g. StartCoroutine). So for anyone else seeing this ReflectionHelper-related errors, question anything that uses Threads (including your dependencies).
@paradizIscool we have code to call unity API in thread,which result in these crash.
Thanks a lot for the solution. We facing same issue. I wan to reproduce crash and figure it out how this happen, so I can avoid it in our project. As you mention, I called Unity API in otherThread. But it work fine. Here is two ways I tried. 1
public class ThreadCallUnityAPI : MonoBehaviour
{
private AndroidJavaObject javaObject;
private GameObject newGo;
public void Invoke()
{
for (var i = 0; i < 1000; ++i)
{
var thread = new System.Threading.Thread(OtherThreadWork1);
thread.Start();
}
}
void OtherThreadWork1()
{
Debug.Log($"Thread {Thread.CurrentThread.Name} started");
for (var i = 0; i < 10; ++i)
{
newGo = null;
newGo = new GameObject("Test"); // everything is fine. Unity API can be called from other threads
newGo.transform.position = new Vector3(i, i, i); // same
}
}
}
2 I also try create Android thread and trigger callback from Unity like this.
// Unity
public class AndroidThreadCallUnityAPI : MonoBehaviour
{
private class UnityCallbackImplementation : AndroidJavaProxy
{
public UnityCallbackImplementation() : base("com.unity3d.player.MyAndroidClass$UnityCallback") { }
public void onCallback()
{
Debug.Log("Called from Android");
var newGo = new GameObject("Test"); // everything is fine. Unity API can be called from other threads
newGo.transform.position = new Vector3(1, 1, 1); // same
}
}
public void Invoke()
{
var javaObject = new AndroidJavaObject("com.unity3d.player.MyAndroidClass");
javaObject.Call("setUnityCallback", new UnityCallbackImplementation());
javaObject.Call("callUnityCallback");
}
}
// Android
public class MyAndroidClass {
private static UnityCallback unityCallback;
public interface UnityCallback {
void onCallback();
}
public void setUnityCallback(UnityCallback callback) {
unityCallback = callback;
}
public void runThread() {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
Log.d("ThreadName", "name is " + Thread.currentThread().getName());
if (unityCallback != null) {
unityCallback.onCallback();
}
}
});
thread.start();
}
public void callUnityCallback() {
runThread();
}
}
Could you please provied some code reproduce this crash ? thanks a lot. @wangjianpeng @dreed-sd
After upgrading the AdMob SDK to version 22.2.0, many crashes occurred in the Android app on Firebase. The upgraded dependencies are as follows:
There are two types of issues:
Exceptions related to 'Thread-XX':
These exceptions are occurring in the ReflectionHelper.getMethodID method.
Exceptions related to 'hashCode':
It is mentioned that these issues are related to Firebase. Despite upgrading both AdMob and Firebase to the latest versions:
The crashes remain unresolved.