Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Issue with DatePickerDialog

Discussion in 'Android' started by cflavio, Nov 14, 2018.

  1. cflavio

    cflavio

    Joined:
    Jul 2, 2013
    Posts:
    13
    Hi, I'm trying to use this Unity's example. I would like to use the DatePickerDialog in my project.

    I've created an empty GameObject and attached the above script to it. But, when I run it I get:

    Code (plain):
    1. java.lang.NoSuchFieldError: no "Ljava/lang/Class;" field "currentActivity" in class "Lcom/unity3d/player/UnityPlayer;" or its superclasses
    2. com.unity3d.player.UnityPlayer.nativeRender(Native Method)
    3. com.unity3d.player.UnityPlayer.c(Unknown Source:0)
    4. com.unity3d.player.UnityPlayer$e$2.queueIdle(Unknown Source:72)
    5. android.os.MessageQueue.next(MessageQueue.java:479)
    6. android.os.Looper.loop(Looper.java:144)
    7. com.unity3d.player.UnityPlayer$e.run(Unknown Source:33)
    8. UnityEngine.AndroidJNISafe.CheckException () (at /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJNISafe.cs:25)
    9. UnityEngine.AndroidJNISafe.GetStaticFieldID (IntPtr clazz, System.String name, System.String sig) (at /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJNISafe.cs:78)
    10. UnityEngine._AndroidJNIHelper.GetFieldID (IntPtr jclass, System.String fieldName, System.String signature, Boolean isStatic) (at /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:1182)
    11. UnityEngine.AndroidJNIHelper.GetFieldID (IntPtr javaClass, System.String fieldName, System.String signature, Boolean isStatic) (at /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJNI.bindings.cs:83)
    12. UnityEngine._AndroidJNIHelper.GetFieldID[AndroidJavaClass] (IntPtr jclass, System.String fieldName, Boolean isStatic) (at /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:1110)
    13. UnityEngine.AndroidJNIHelper.GetFieldID[AndroidJavaClass] (IntPtr jclass, System.String fieldName, Boolean isStatic) (at /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJNI.bindings.cs:165)
    14. UnityEngine.AndroidJavaObject._GetStatic[AndroidJavaClass] (System.String fieldName) (at /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:480)
    15. UnityEngine.AndroidJavaObject.GetStatic[AndroidJavaClass] (System.String fieldName) (at /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJava.bindings.cs:57)
    16. ExampleClass.OnGUI () (at C:/Path/To/ExampleClass.cs:16)
    17. AndroidJavaException: java.lang.NoSuchFieldError: no "Ljava/lang/Class;" field "currentActivity" in class "Lcom/unity3d/player/UnityPlayer;" or its superclasses
    and obviously it doesn't work. What am I missing? Thank you!
     
  2. crutchcorn

    crutchcorn

    Joined:
    Mar 8, 2019
    Posts:
    1
    I had this issue myself when trying to figure this out. Replace `AndroidJavaClass` with `
    AndroidJavaObject`. Here's the code that's worked for me:
    ```
    var player = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
    var activity = player.GetStatic<AndroidJavaObject>("currentActivity");
    ```
     
  3. vijaybalastudios

    vijaybalastudios

    Joined:
    Jul 21, 2019
    Posts:
    1
    how ?