AuthenticationFailedException java.lang.NullPointerException on connect
Issue last reproduced Dec 29, 2019, but happened (occasionally, not always) multiple times before.
SDK Version: Last reproduced with spotify-app-remote 0.7.0, but happened before with 0.6.3 as well.
OS Version: Android 8.0
Scope(s): Connecting to Spotify.
Steps to reproduce:
Call SpotifyAppRemote.connect.
Actual behaviour:
Sometimes it results in the following error "com.spotify.android.appremote.api.error.AuthenticationFailedException: {"message":"java.lang.NullPointerException: Attempt to invoke virtual method \u0027java.lang.String java.lang.String.trim()\u0027 on a null object reference"} Once the error occurs, it persists on every attempt to connect for several hours, then usually disappears and connection works normally, can work normally for days until the issue reappears. I thought initially that it is caused by the fact that the same client ID (same app registered on Spotify web site) is used in our several mobile apps (thought there is an undocumented restriction in Spotify SDK that every movile app needs to use a separate client id), but even after registering a new client id with Spotify and using it in one mobile app exclusively, the issue happened again (connection worked fine usign the new client id for a couple of das, but then the issue reappeared), so I currently don't know what triggers it and how to avoid it.
Exception still happens, on and off. Here is the log from logcat: 2020-01-04 09:03:01.605 29979-30068/com.brainglass.lingoal.coach D/SPOTIFY_APP_REMOTE: Start remote client 2020-01-04 09:03:01.619 29979-30068/com.brainglass.lingoal.coach D/SPOTIFY_APP_REMOTE: Connecting to Spotify service 2020-01-04 09:03:01.633 29979-29979/com.brainglass.lingoal.coach D/SPOTIFY_APP_REMOTE: Spotify service connected 2020-01-04 09:03:01.823 29979-30187/com.brainglass.lingoal.coach D/SPOTIFY_APP_REMOTE: Message from Spotify: [3,{"message":"java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.trim()' on a null object reference"},"com.spotify.error.client_authentication_failed"] 2020-01-04 09:03:01.833 29979-29979/com.brainglass.lingoal.coach D/SPOTIFY_APP_REMOTE: Connection failed. com.spotify.protocol.client.error.RemoteClientException: {"message":"java.lang.NullPointerException: Attempt to invoke virtual method \u0027java.lang.String java.lang.String.trim()\u0027 on a null object reference"} at com.spotify.protocol.client.RemoteWampClient.getRemoteClientException(RemoteWampClient.java:139) at com.spotify.protocol.client.RemoteWampClient.access$200(RemoteWampClient.java:16) at com.spotify.protocol.client.RemoteWampClient$1.onAbort(RemoteWampClient.java:44) at com.spotify.protocol.client.WampRouterImpl.routeAbort(WampRouterImpl.java:100) at com.spotify.protocol.client.WampRouterImpl.route(WampRouterImpl.java:26) at com.spotify.protocol.client.AppProtocolCommunicator.onData(AppProtocolCommunicator.java:78) at com.spotify.android.appremote.internal.RemoteServiceIo.handleMessage(RemoteServiceIo.java:113) at com.spotify.android.appremote.internal.RemoteServiceIo.access$000(RemoteServiceIo.java:47) at com.spotify.android.appremote.internal.RemoteServiceIo$IncomingHandler.handleMessage(RemoteServiceIo.java:91) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:169) at android.os.HandlerThread.run(HandlerThread.java:65) 2020-01-04 09:03:01.834 29979-29979/com.brainglass.lingoal.coach D/SPOTIFY_APP_REMOTE: Stop remote client
Also running into this issue. It seems instantiation a Connector.ConnectionListener has, without any code changes on the user's part, changed behavior (I only started seeing this issue today).
Also running into this issue.
However in my case the message is different and so random:
Caused by com.spotify.protocol.client.error.RemoteClientException: {"message":"java.lang.Throwable: Failed resolving \u0027hm://bakery/accountscookie\u0027, got status code: 0"}
at com.spotify.protocol.client.RemoteWampClient.getRemoteClientException(RemoteWampClient.java:139)
at com.spotify.protocol.client.RemoteWampClient.access$200(RemoteWampClient.java:16)
at com.spotify.protocol.client.RemoteWampClient$1.onAbort(RemoteWampClient.java:43)
at com.spotify.protocol.client.WampRouterImpl.routeAbort(WampRouterImpl.java:100)
at com.spotify.protocol.client.WampRouterImpl.route(WampRouterImpl.java:26)
at com.spotify.protocol.client.AppProtocolCommunicator.onData(AppProtocolCommunicator.java:78)
at com.spotify.android.appremote.internal.RemoteServiceIo.handleMessage(RemoteServiceIo.java:111)
at com.spotify.android.appremote.internal.RemoteServiceIo.access$000(RemoteServiceIo.java:45)
at com.spotify.android.appremote.internal.RemoteServiceIo$IncomingHandler.handleMessage(RemoteServiceIo.java:89)
Edit: exactly same issue than #192