You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to call the new method ApplicationPreferences.SetString("key", "value"), which was added in ApplicationPreferences API to manage GMA preferences. However, I get this exception:
AndroidJavaException: java.lang.NoSuchMethodError: no non-static method with name='getDefaultSharedPreferences' signature='()Ljava/lang/Object;' in class Ljava.lang.Object;
java.lang.NoSuchMethodError: no non-static method with name='getDefaultSharedPreferences' signature='()Ljava/lang/Object;' in class Ljava.lang.Object;
at com.unity3d.player.ReflectionHelper.getMethodID(Unknown Source:162)
at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0)
at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:268)
at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.AndroidJNISafe.CallStaticObjectMethod (System.IntPtr clazz, System.IntPtr methodID, UnityEngine.jvalue[] args) [0x00000] in <000000000000000000000000
Relevant Code:
The problem is in the way of getting the Java interface SharedPreferences.Editor.
So instead of this
AndroidJavaObject androidJavaObject = new AndroidJavaClass("android.preference.PreferenceManager").Call<AndroidJavaObject>("getDefaultSharedPreferences").Call<AndroidJavaObject>("edit");
it should be this
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject androidJavaObject = new AndroidJavaClass("android.preference.PreferenceManager").CallStatic<AndroidJavaObject>("getDefaultSharedPreferences", currentActivity).Call<AndroidJavaObject>("edit");
The text was updated successfully, but these errors were encountered:
[REQUIRED] Step 1: Describe your environment
[REQUIRED] Step 2: Describe the problem
Steps to reproduce:
I was trying to call the new method ApplicationPreferences.SetString("key", "value"), which was added in ApplicationPreferences API to manage GMA preferences. However, I get this exception:
Relevant Code:
The problem is in the way of getting the Java interface SharedPreferences.Editor.
So instead of this
it should be this
The text was updated successfully, but these errors were encountered: