Search Unity

[BUG] ANDROIDJAVACLASS.GETSTATIC RETURNS NULL WHEN BEING BUILT TO ANDROID DEVICE

Discussion in 'Android' started by Aokkii, Sep 12, 2019.

  1. Aokkii

    Aokkii

    Joined:
    Nov 3, 2013
    Posts:
    118
    [bug]


    please enter the link and give it a vote please, so unity can notice and fix it.


    https://issuetracker.unity3d.com/is...turns-null-when-being-built-to-android-device

    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));
    }
     
    jimblackler0 likes this.