I donβt have all the details about your project, and mistakes that cannot be reproduced inside the house are the worst. Nevertheless, I will try to give some advice on what is happening. Perhaps these tips may shed some light and help you figure out the cause of the error:
CalledFromWrongThreadException
In Android, access to a view is only available from the stream that created it. This is true for other environments ( WinForms , WPF , etc.). This exception means that something is trying to access some user interface element (SurfaceView) from the wrong stream.
com.unity3d.player.UnityPlayer $ c.run
The stack trace comes from some special Unity plumbing code. Although this does not give a hint where this call comes from (in C # code), it may mean that the code appeared in C # (using calls to AndroidJavaObject or AndroidJavaClass). Unity scripting thread is not the same as the main Android thread, so this makes sense along with the type of exception you get.
As a test, I used this code to simulate the same exception:
using (var actClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { var activity = actClass.GetStatic<AndroidJavaObject>("currentActivity");
This led to the following exception, which is very similar to the one you get (at least in its root).
E / ViewRootImpl (19244): com.test.crash.GameActivity: Only the original thread that created the view hierarchy can touch its views. E / ViewRootImpl (19244): java.lang.RuntimeException E / ViewRootImpl (19244): when android.view.ViewRootImpl.checkThread (ViewRootImpl.java:7105) E / ViewRootImpl (19244): when android.view.ViewRootImpl.invalidateChildInParent ViewRootImpl.java:1139) E / ViewRootImpl (19244): with android.view.ViewGroup.invalidateChild (ViewGroup.javahaps2525) E / ViewRootImpl (19244): with android.view.View.invalidateInternal (View.java:13669) E / ViewRootImpl (19244): when android.view.View.invalidate (View.java:13633) E / ViewRootImpl (19244): on android.view.View.onFocusChanged (View.java:6204) E / ViewRootImpl (19244) : when android.view.View.clearFocusInternal (View.java:6089) E / ViewRootImpl (19244): on android.view.View.unFocus (View.java:6122) E / ViewRootImpl (19244): when android.view. ViewGroup.unFocus (ViewGroup.java:997) E / ViewRootImpl (19244): with android.view.ViewGroup.removeAllViewsInLayout (ViewGroup.java:4946) E / ViewRootImpl (19244): with android.view.ViewGroup.removeAllViews (ViewGroup. java : 4905) E / ViewRootImpl (19244): when com.android.internal.policy.PhoneWindow.setContentView (PhoneWindow.java:410) E / ViewRootImpl (19244): when android.app.Activity.setContentView (Activity.java:2423 ) E / ViewRootImpl (19244): at com.unity3d.player.UnityPlayer.nativeRender (own method) E / ViewRootImpl (19244): at com.unity3d.player.UnityPlayer.a (Unknown Source) E / ViewRootImpl (19244): at com.unity3d.player.UnityPlayer $ c $ 1.handleMessage (Unknown source) E / ViewRootImpl (19244): at android.os.Handler.dispatchMessage (Handler.java:98) E / ViewRootImpl (19244): at android.os .Looper.loop (Looper.java:173) E / ViewRootImpl (19244): at com.unity3d.player.UnityPlayer $ c.run (Unknown source)
Summary
As I mentioned earlier, this only gives you a direction where to look. We hope you can find potential locations that may be causing this (possibly the plugin code). I would be happy to help (in the comments or feel free to contact me ).
source share