FlutterAppauthPlugin.java line, io.crossingthestreams.flutterappauth.FlutterAppauthPlugin.a
Is there any way to fix this issue?
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void net.openid.appauth.g.a(net.openid.appauth.r, net.openid.appauth.g$b)' on a null object reference
at io.crossingthestreams.flutterappauth.FlutterAppauthPlugin.a(FlutterAppauthPlugin.java:82)
at io.crossingthestreams.flutterappauth.FlutterAppauthPlugin.access$300(FlutterAppauthPlugin.java)
at io.crossingthestreams.flutterappauth.FlutterAppauthPlugin$4.onFetchConfigurationCompleted(FlutterAppauthPlugin.java:6)
at net.openid.appauth.AuthorizationServiceConfiguration$ConfigurationRetrievalAsyncTask.a(AuthorizationServiceConfiguration.java:13)
at net.openid.appauth.AuthorizationServiceConfiguration$ConfigurationRetrievalAsyncTask.onPostExecute(AuthorizationServiceConfiguration.java:2)
at android.os.AsyncTask.finish(AsyncTask.java:755)
at android.os.AsyncTask.access$900(AsyncTask.java:192)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:772)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7562)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Button Click code
@override
Future<AuthorizationTokenResponse?> login(TenantCatLogModel? tenantCatLogModel) async {
FlutterAppAuth appAuth = FlutterAppAuth();
final String _issuer = '${tenantCatLogModel?.authorityUrl}';
final AuthorizationServiceConfiguration _serviceConfiguration = AuthorizationServiceConfiguration(
'${tenantCatLogModel?.authorityUrl}/connect/authorize', '${tenantCatLogModel?.authorityUrl}/connect/token');
return appAuth
.authorizeAndExchangeCode(AuthorizationTokenRequest(
_clientId, _redirectUrl,
issuer: _issuer,
scopes: _scopes,
promptValues: ['login'],
serviceConfiguration: _serviceConfiguration,
preferEphemeralSession: Platform.isIOS
)).catchError((e) async {
return null;
}).then((value) async {
log('access token -> ${value?.accessToken}');
if (value?.refreshToken != null) {
await SecureStore().setRToken(value?.refreshToken);
return value;
} else {
return null;
}
});
}
Not something I can look into without a minimal app that can reproduce the issue so it would need to be something you'd have to debug to find out
We are seeing a very similar error in our crashlytics:
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void net.openid.appauth.g.a(net.openid.appauth.r, net.openid.appauth.g$b)' on a null object reference
at io.crossingthestreams.flutterappauth.FlutterAppauthPlugin.a(FlutterAppauthPlugin.java:82)
at io.crossingthestreams.flutterappauth.FlutterAppauthPlugin.access$300(FlutterAppauthPlugin.java)
at io.crossingthestreams.flutterappauth.FlutterAppauthPlugin$4.onFetchConfigurationCompleted(FlutterAppauthPlugin.java:6)
at net.openid.appauth.AuthorizationServiceConfiguration$ConfigurationRetrievalAsyncTask.a(AuthorizationServiceConfiguration.java:13)
at net.openid.appauth.AuthorizationServiceConfiguration$ConfigurationRetrievalAsyncTask.onPostExecute(AuthorizationServiceConfiguration.java:2)
at android.os.AsyncTask.finish(AsyncTask.java:771)
at android.os.AsyncTask.access$900(AsyncTask.java:199)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:264)
at android.app.ActivityThread.main(ActivityThread.java:8245)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:632)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049)

From what I can deduce, it's an issue related to configuration fetching. Have not been able to reproduce it.
Based on the stacktrace, it's executing this block:
https://github.com/MaikuB/flutter_appauth/blob/92cc21bb7e07684adc1c5265f63d1429982b9451/flutter_appauth/android/src/main/java/io/crossingthestreams/flutterappauth/FlutterAppauthPlugin.java#L352-L354
But the authorizationService seems to be null?
Could it be that the config callback gets triggered, but everything is somehow already disposed?
@JordyLangen that I've seen based on what's been provided but it doesn't help much given there's a line to assign that authorizationService. To properly diagnose this issue would require steps to reproduce
@MaikuB could it be that either insecureAuthorizationService or defaultAuthorizationService is null? So then authorizationService is assigned to be null...
Would be good to have this crash fixed!
@PieterAelse Except no one has provided info on how it could be null. The code is open-source so you should be able to see both of those are being set when the Flutter engine is being attached. It's only set to null when the plugin is meant to clean up resources. If you're experiencing the issue then since it is open-source, you can debug further, try to fix it and submit a PR back to the repository