LIFX Android SDK gateway descriptor service is Null

I’m using android to control LIFX via LAN network, When I trying to run the examples included in the package here:https://github.com/LIFX/lifx-sdk-android, I got a error pointed to
public String getProtocolString()
{
return service.toString();
}
and the application is then crashed and the exception messages are following:

dRuntime: FATAL EXCEPTION: main
Process: android.java.lifx.lifxlib, PID: 15892
java.lang.NullPointerException: Attempt to invoke virtual method ‘java.lang.String lifx.java.android.entities.internal.structle.LxProtocolDevice$Service.toString()’ on a null object reference
at lifx.java.android.entities.internal.LFXGatewayDescriptor.getProtocolString(LFXGatewayDescriptor.java:84)
at lifx.java.android.entities.internal.LFXGatewayDescriptor.toString(LFXGatewayDescriptor.java:91)
at lifx.java.android.network_context.internal.transport_manager.lan.LFXLANTransportManager.gatewayDiscoveryControllerDidUpdateEntry(LFXLANTransportManager.java:351)
at lifx.java.android.network_context.internal.transport_manager.lan.gateway_discovery.LFXGatewayDiscoveryController.handleStatePANGatewayMessage(LFXGatewayDiscoveryController.java:127)
at lifx.java.android.network_context.internal.transport_manager.lan.gateway_discovery.LFXGatewayDiscoveryController$1.run(LFXGatewayDiscoveryController.java:58)
at lifx.java.android.network_context.internal.transport_manager.LFXTransportManager.sendObserverCallbacksForMessage(LFXTransportManager.java:144)
at lifx.java.android.network_context.internal.transport_manager.lan.LFXLANTransportManager.gatewayConnectionDidReceiveMessageFromHost(LFXLANTransportManager.java:335)
at lifx.java.android.network_context.internal.transport_manager.gateway_connection.LFXUDPGatewayConnection.udpSocketDidReceiveDataFromAddressWithFilterContext(LFXUDPGatewayConnection.java:289)
at lifx.java.android.network_context.internal.transport_manager.gateway_connection.LFXUDPGatewayConnection.notifyMessageReceived(LFXUDPGatewayConnection.java:324)
at lifx.java.android.network_context.internal.transport_manager.gateway_connection.LFXSocketGeneric.notifyAllListenersMessageReceived(LFXSocketGeneric.java:238)
at lifx.java.android.network_context.internal.transport_manager.gateway_connection.LFXSocketGeneric$1.handleMessage(LFXSocketGeneric.java:168)
at android.os.Handler.dispatchMessage(Handler.java:102)

How can I fix this?

The API is old and not updated for the latest firmware and is also not being maintained.
You would need to write your own LAN method or search for alternatives.

Thank you so much. I’ve changed to used python.

Good idea. Don’t forget to search Github for Lightsd

1 Like