Search Issue Tracker

Fixed in 2020.1.X

Fixed in 2019.2.X, 2019.3.X

Votes

13

Found in

2019.2.0a1

2019.2.0f1

Issue ID

1179268

Regression

Yes

[Android] AndroidJavaClass.GetStatic returns null when being built to Android device

Android

-

To reproduce:
1. Open attached project
2. Build and run to android device
3. Check Logcat

Actual result: In logcat can see this line: TEST_CONSTANT: null
Expected result: In logcat should be a line with TEST_CONSTANT: org.example.constant

Reproduced in: 2019.2.0a1; 2020.1.0a2
No repro: 2019.1.14f1

Note: on editor returns normally

Tested with:
VLNQA00277, Asus ROG Phone (ASUS_Z01QD), Android 8.1.0, CPU: Snapdragon 845 SDM845, GPU: Adreno (TM) 630
VLNQA00138, Huawei P20 Pro (CLT-L29), Android 8.1.0, CPU: HiSilicon Kirin 970, GPU: Mali-G72
VLNQA00262, Sony Xperia XZ Premium (G8141), Android 9, CPU: Snapdragon 835 MSM8998, GPU: Adreno (TM) 540

void Start()
{
string constant;
using (AndroidJavaClass MyClass = new AndroidJavaClass("org.example.MyPackage.MyPlugin"))
{
constant = MyClass.GetStatic<string>("TEST_CONSTANT");
}
Debug.Log("* TEST_CONSTANT: " + (constant == null ? "null" : constant));
}

Comments (6)

  1. jimblackler_unity

    Mar 19, 2020 12:28

    This is happening for me in 2019.3.5f1.

  2. AlekseyLaz

    Dec 03, 2019 13:09

  3. AlekseyLaz

    Dec 03, 2019 12:55

    This fix breaks AndroidJavaClass.
    Starting 2019.2.11 we get "AndroidJavaException: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Class.getName()' on a null object reference"

    with this code calling CallStatic:

    using (var pluginClass = new AndroidJavaClass("com.prime31.analytics.FlurryAnalytics"))
    {
    _plugin = pluginClass.CallStatic<AndroidJavaObject>("instance");
    }

    2019.2.10 works fine.

  4. dean0

    Dec 03, 2019 04:36

    This doesn't seem to be fixed for me in 2019.2.14

  5. robertsze

    Nov 12, 2019 11:41

    Since 2019.2.11 we started experiencing this crash (when it should have been resolved actually), never had a problem before, crashes 100% of the time here:

    // find the plugin instance
    using( var pluginClass = new AndroidJavaClass( "com.prime31.EtceteraPlugin" ) )
    _plugin = pluginClass.CallStatic<AndroidJavaObject>( "instance" );

    Works fine with 2019.2.10 and below

  6. logantesla1214

    Oct 02, 2019 07:48

    Actual result: In logcat can see this line: TEST_CONSTANT: null
    Expected result: In logcat should be a line with TEST_CONSTANT: org.example.constant

    Reproduced in: 2019.2.0a1; 2020.1.0a2
    No repro: 2019.1.14f1

    Note: on editor returns normally

Add comment

Log in to post comment