okta-sdk-appauth-android icon indicating copy to clipboard operation
okta-sdk-appauth-android copied to clipboard

NullPointerException upon OktaAppAuth init

Open MathieuCorti opened this issue 5 years ago • 1 comments

Issue description

When launched on a Galaxy Tab A, the library throws a NullPointerException.

Configuration details

Device

Samsung Galaxy Tab A 10.1 (SM-T515) Android 9.0

Okta SDK

Version 0.2.4

Stack

java.lang.NullPointerException: Attempt to invoke interface method 'void com.okta.appauth.android.Okta AppAuth$Okta Auth Listener.Token Failure(net.openid.appauth.AuthorizationException) on a null object reference at com.okta.appauth.android.OktaAppAuth.handleConfigurationRetrievalResult(Ckt A uth.java:751) at com.okta.appauth.android.OktaAppAuth.access$700(OktaAppAuth.java:73), at com.okta appauth.android.OktaAppAuth$12.onFetchConfiguration Completed (OktaApp Auth.java:674) at net.openid.appauth.AuthorizationServiceConfiguration$ConfigurationRetrievalAsyncTas k.onPostExecute(AuthorizationServiceConfiguration.java:377) at net.openid.appauth.AuthorizationServiceConfiguration$Configuration RetrievalAsyncTas k.onPostExecute(AuthorizationServiceConfiguration.java:320) at android.os.AsyncTask.finish(AsyncTask.java:695) at android.os.AsyncTask.access$600(AsyncTask.java:180) at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:712) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7072) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)

More details

The auth has been working fine on multiples devices, but when we tried to run it on a Galaxy Tab (Android 9), the library crashed every time. We've tested on multiples Galaxy Tab with the same result. We've also tried to remove the JSON configuration file on a working device to see if that reproduces the same error, but it didn't so we assumed that the file should be correctly loaded.

MathieuCorti avatar Aug 30 '19 08:08 MathieuCorti

@MathieuCorti It looks like the callback OktaAuthListener is null. Check if you are calling OktaAppAuth.dispose anywhere before or after OktaAppAuth.init. Since init uses a separate thread to do the initialization, this can cause a number of timing issues if init/dispose is called closely together. Or if you try to do an api call before init finishes. Unfortunately init doesn't provided a signal to the app when initialization is completed.

FeiChen-okta avatar Aug 30 '19 17:08 FeiChen-okta