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
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));
}
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- UI Overlay Image gets darker on each Camera when multiple Cameras are used
- Assertion failed on expression: 'scriptedImporterClass == SCRIPTING_NULL error when opening the standalone profiler window
- Disabled assets in Import Unity Package window aren't tracked but count as being selected by user
- [Windows] Crash on GetManagerFromContext when video is playing and creating High Definition 3D Projects after FMOD failed to switch back to normal output Error appeared
- GC Alloc produced when adding items to MultiColumnListView with Auto Assign Binding
jimblackler_unity
Mar 19, 2020 12:28
This is happening for me in 2019.3.5f1.
AlekseyLaz
Dec 03, 2019 13:09
Report submitted
http://fogbugz.unity3d.com/default.asp?1202753_fe63le0mvlto17ad
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.
dean0
Dec 03, 2019 04:36
This doesn't seem to be fixed for me in 2019.2.14
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
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