[unity] no static field with name=’currentActivity’

유니티에서 안드로이드와 연동하는 소스를 export 하고 실행했더니 이런 오류가 뜬다.

AndroidJavaException: java.lang.NoSuchFieldError: no static field with name='currentActivity' signature='Ljava/lang/Object;' in class Lkr/mint/widgetwithunity/MainActivity;
  at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <filename unknown>:0 
  at UnityEngine.AndroidJNISafe.GetStaticFieldID (IntPtr clazz, System.String name, System.String sig) [0x00000] in <filename unknown>:0 
  at UnityEngine._AndroidJNIHelper.GetFieldID (IntPtr jclass, System.String fieldName, System.String signature, Boolean isStatic) [0x00000] in <filename unknown>:0 
  at UnityEngine.AndroidJNIHelper.GetFieldID (IntPtr javaClass, System.String fieldName, System.String signature, Boolean isStatic) [0x00000] in <filename unknown>:0 
  at UnityEngine._AndroidJNIHelper.GetFieldID[AndroidJavaObject] (IntPtr jclass, System.String fieldName, Boolean isStatic) [0x00000] in <filename unknown>:0 
  at UnityEngine.AndroidJNIHelper.GetFieldID[AndroidJavaObject] (IntPtr jclass, System.String fieldName, Boolean isStatic) [0x00000] in 
NullReferenceException: Object reference not set to an instance of an object
  at AndroidManager.CallAndroid () [0x00000] in <filename unknown>:0 
  at Buttons.OnGUI () [0x00000] in <filename unknown>:0

 

 

 

void Awake()
{
  AndroidJavaClass jc = new AndroidJavaClass("kr.susemi99.testunity.MainActivity");
  curActivity = jc.GetStatic<AndroidJavaObject>("currentActivity");
}

패키지이름이 나오길래 당연히 이렇게 썼었는데, 알고보니 저기는 바꾸면 안되는거였다.

 

 

 

 

void Awake()
{
  AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
  curActivity = jc.GetStatic<AndroidJavaObject>("currentActivity");
}

그냥 이거 그대로 써야한다.

 

소스 참고 : http://westwoodforever.blogspot.kr/2013/12/unity3d-prime31.html