Skip to content

Null Dimensions Cause Native Errors #50

@Moe-Baker

Description

@Moe-Baker

On Android, setting a dimension to null will not cause an error within the Unity console, but it will cause native issues with the GA plugin.

Error/GameAnalytics: Error on GA thread
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
	at com.gameanalytics.sdk.events.GAEvents.addDimensionsToEvent(GAEvents.java:1320)
	at com.gameanalytics.sdk.events.GAEvents.addDesignEvent(GAEvents.java:1065)
	at com.gameanalytics.sdk.GameAnalytics$24.execute(GameAnalytics.java:1294)
	at com.gameanalytics.sdk.threading.GAThreading$1.run(GAThreading.java:32)
	at java.util.TimerThread.mainLoop(Timer.java:634)
	at java.util.TimerThread.run(Timer.java:577)

Now this isn't exactly an issue, but one might mistakenly think that setting a dimension to null will clear that dimension, and then one might not notice any issues in development builds as the error is reported within ADB, not as a Unity error, wherein one might spend hours trying to hunt the reason his analytics are mis-reporting (ask me how I know).

Here is some sample code:
Bad Code: SDK.SetCustomDimension01(first ? "first_session" : null);
Good Code: SDK.SetCustomDimension01(first ? "first_session" : "regular_session");

I'm not sure how the dimension system actually works, and how one can "remove" a dimension, but this whole null not giving any Unity errors seems like it would cause problems for various people, especially considering that the Game Analytics website indicates that null is a valid value for a dimension

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions