Search Issue Tracker

Fixed in 2020.1

Fixed in 2019.2, 2019.3

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 (5)

  1. 9d0ae276bd9c48a50d8f4672e3f81da3?d=mm

    AlekseyLaz

    Dec 03, 2019 13:09

  2. 9d0ae276bd9c48a50d8f4672e3f81da3?d=mm

    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.

  3. 71444b298a01cb9245b35f339fcac5a1?d=mm

    dean0

    Dec 03, 2019 04:36

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

  4. 465ca539808c833f1f55c76a34a693b1?d=mm

    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

  5. B65803c199f4251fd2f92ef08985252d?d=mm

    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

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.