Null problem in okta authorized request call from an android app

I took the android app that can be downloaded when a native app is created in okta. In the authorized fragment, I’m trying to call my okta protected api that runs in a spring boot app:

private fun callMyApi() {

val uri: Uri = Uri.parse("")
val properties = hashMapOf<String, String>()
val postParameters: HashMap<String, String> = HashMap()

sessionClient?.run {
        object : RequestCallback<JSONObject, AuthorizationException?> {
            override fun onSuccess(result: JSONObject) {
                info_view.text = "it worked!!!"
                Snackbar.make(info_view, getString(R.string.success), Snackbar.LENGTH_SHORT)

            override fun onError(
                error: String,
                exception: AuthorizationException?
            ) {
                info_view.text = "it did not work screwed:"
                Snackbar.make(info_view, getString(R.string.error), Snackbar.LENGTH_SHORT)


However, I keep on getting the following error, independent of whether I put empty collections instead of the two nulls or not:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.okta.oidc, PID: 8824
    java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter error
        at com.okta.oidc.fragments.AuthorizedFragment$callMyStravaApi$$inlined$run$lambda$1.onError(Unknown Source:2)
        at com.okta.oidc.fragments.AuthorizedFragment$callMyStravaApi$$inlined$run$lambda$1.onError(AuthorizedFragment.kt:117)
        at com.okta.oidc.clients.sessions.SessionClientImpl.lambda$null$17(
        at com.okta.oidc.clients.sessions.-$$Lambda$SessionClientImpl$ Source:4)
        at android.os.Handler.handleCallback(
        at android.os.Handler.dispatchMessage(
        at android.os.Looper.loop(
        at java.lang.reflect.Method.invoke(Native Method)
I/Process: Sending signal. PID: 8824 SIG: 9
Disconnected from the target VM, address: 'localhost:60989', transport: 'socket'

What could be the reason? How can I avoid this error?
I have also noticed that this method is deprecated, what other method should I call?

@advii Can you please add the details for the Okta sdk you referred? What is the version you are using? Is there a link?

Hi Lijia, sorry - the problem has been solved by exchanging error: String with error: String?

@advii It is glad to know the issue is resolved. So the solution is adding an error handling?

well the example code was Java, when I automatically migrated it to kotlin it did not get the hint that the error string might be null.

@advii I see. you meant it does not contains the null check right? Do you have the link for the sample code?

Hi Lijia,
it’s rather easy:

the sample you publish in the quick start for android:

    sessionClient.authorizedRequest(uri, properties, postParameters, HttpConnection.RequestMethod.POST,
        new RequestCallback<JSONObject, AuthorizationException>() {
            public void onSuccess(@NonNull JSONObject result) {
                //handle JSONObject result.

            public void onError(String error, AuthorizationException exception) {
                //handle error

the second method has been translated automatically to kotlin in Intellijas

                override fun onError(
                    error: String,
                    exception: AuthorizationException?

but it has to be

                override fun onError(
                    error: String?,
                    exception: AuthorizationException?

No problem on the Okta side.

@advii Ok. I see. Thanks for the clarification. Then I’ll close this topic.