Reputation: 53
I am using unity 2019.4.24f1 and unity remote 5 app connected with USB.
var javaUnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
var currentActivity = javaUnityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
This error is thrown from currentActivity
line.
Exception: Field currentActivity or type signature not found
UnityEngine._AndroidJNIHelper.GetFieldID (System.IntPtr jclass, System.String fieldName, System.String signature, System.Boolean isStatic) (at /Users/bokken/buildslave/unity/build/Modules/AndroidJNI/AndroidJava.cs:1448)
UnityEngine.AndroidJNIHelper.GetFieldID (System.IntPtr javaClass, System.String fieldName, System.String signature, System.Boolean isStatic) (at /Users/bokken/buildslave/unity/build/Modules/AndroidJNI/AndroidJNI.bindings.cs:79)
UnityEngine._AndroidJNIHelper.GetFieldID[ReturnType] (System.IntPtr jclass, System.String fieldName, System.Boolean isStatic) (at /Users/bokken/buildslave/unity/build/Modules/AndroidJNI/AndroidJava.cs:1361)
UnityEngine.AndroidJNIHelper.GetFieldID[FieldType] (System.IntPtr jclass, System.String fieldName, System.Boolean isStatic) (at /Users/bokken/buildslave/unity/build/Modules/AndroidJNI/AndroidJNI.bindings.cs:172)
UnityEngine.AndroidJavaObject._GetStatic[FieldType] (System.String fieldName) (at /Users/bokken/buildslave/unity/build/Modules/AndroidJNI/AndroidJava.cs:664)
UnityEngine.AndroidJavaObject.GetStatic[FieldType] (System.String fieldName) (at /Users/bokken/buildslave/unity/build/Modules/AndroidJNI/AndroidJava.cs:274)
Upvotes: 1
Views: 12519
Reputation: 70
Android plugin requires android device or emulator to set current activity.
Upvotes: 1
Reputation: 53
In case anyone stuck with the same issue. The emulator & unity remote 5 app connected with USB didn't work at least. But creating a apk build & running it on the android device was successful.
Upvotes: 4