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. Dismiss Notice

[2019.2.14f1 or above] AndroidJavaException: java.lang.NullPointerException

Discussion in 'Android' started by Akiracc, Dec 11, 2019.

  1. Akiracc

    Akiracc

    Joined:
    Aug 14, 2014
    Posts:
    4
    Code (CSharp):
    1. 2019-12-10 22:53:43.570 22973-23004/com.xxxx.NewUnityProject E/Unity: AndroidJavaException: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Class.getName()' on a null object reference
    2.     java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Class.getName()' on a null object reference
    3.         at com.unity3d.player.ReflectionHelper.getMethodID(Unknown Source:224)
    4.         at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
    5.         at com.unity3d.player.UnityPlayer.c(Unknown Source:0)
    6.         at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95)
    7.         at android.os.Handler.dispatchMessage(Handler.java:102)
    8.         at android.os.Looper.loop(Looper.java:201)
    9.         at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
    10.       at UnityEngine._AndroidJNIHelper.GetMethodID (System.IntPtr jclass, System.String methodName, System.String signature, System.Boolean isStatic) [0x00041] in /Users/builduser/buildslave/unity/build/Modules/AndroidJNI/AndroidJava.cs:1396
    11.       at UnityEngine.AndroidJNIHelper.GetMethodID (System.IntPtr java
    12.  
    Reproducible with: 2019.2.15f1 2019.2.14f1
    No problem with : 2019.2.8f1

    The demon project is in the attached files.
     

    Attached Files:

  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,637
    Akiracc likes this.
  3. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,637
    So I've found the cause for it. The fix is coming.
    If you need it urgently, then pass the exact class for static method you try to call (the one that defines that method). Currently it doesn't walk up the hierarchy and only searches for static methods in the given class.
     
    Akiracc likes this.
  4. jnbt

    jnbt

    Joined:
    Jul 8, 2013
    Posts:
    11
    We can confirm the problem: calling a static "inherited" method on a Java class does not work in all recent version of Unity 2019.2.
    Switching over to call the static method on the implementing class fixes the problem (and is IMHO also the better way).
     
  5. Radegast

    Radegast

    Joined:
    Dec 2, 2016
    Posts:
    3
    Trond_Tactile and kh-liu like this.
  6. Trond_Tactile

    Trond_Tactile

    Joined:
    May 25, 2016
    Posts:
    17
    The ticket mentions 2019.2.22f1, but that version is not available on the downloads page. Please provide a link for this version.
     
  7. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    2019.2 is no longer supported, please switch to 2019 LTS