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
- Articulation Body with 'Revolute' Joint Type has erratic behavior when Upper Limit is set to above 360
- WebGL Player fails to render Scene when Terrain with Detail Mesh is added and WebGPU Graphics API is used
- Inconsistent errors are logged when different types are passed into the Query "Q<>" method in UIToolkit and the ancestor VisualElement is null
- Crash on GetMaterialPropertyByIndex when opening a specific Scene
- Discrepancies in the styling are present when using a TSS file instead of a USS file in custom EditorWindow
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