Caused by: java.lang.ClassNotFoundException: Didn't find class "com.linusu.flutter_appauth.CallbackActivity" on path: DexPathList[[zip file "/data/app/~~oiOQSC4LyrKH8vDyPfAFKg==/com.marworx.ssoapp-ZpELo6-QfZ-R75H69XVGJg==/base.apk"],nativeLibraryDirectories=[/data/app/~~oiOQSC4LyrKH8vDyPfAFKg==/com.marworx.ssoapp-ZpELo6-QfZ-R75H69XVGJg==/lib/arm64, /data/app/~~oiOQSC4LyrKH8vDyPfAFKg==/com.marworx.ssoapp-ZpELo6-QfZ-R75H69XVGJg==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
How to resolve this crashing issue in flutter android app
The error ClassNotFoundException: Didn't find class "com.linusu.flutter_appauth.CallbackActivity"
indicates that the required CallbackActivity
class is missing from your project configuration. To resolve this issue, follow these steps:
Open the android/app/src/main/AndroidManifest.xml
file and add the redirect URI scheme as shown below:
<activity
android:name="net.openid.appauth.RedirectUriReceiverActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="com.yourapp.app"
android:host="oauthredirect" />
</intent-filter>
</activity>
Include the required dependencies in your pubspec.yaml
file:
dependencies:
flutter_appauth: ^5.0.0
flutter_microsoft_authentication: ^0.1.0
http: ^0.15.0
Run flutter pub get
to fetch the dependencies.
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>com.yourapp.app</string>
</array>
</dict>
</array>
Thanks to @Gerrit van Huyssteen for the steps. I referred this doc for Flutter Mobile SSO with Microsoft Login
import 'package:flutter_microsoft_authentication/flutter_microsoft_authentication.dart';
...
FlutterMicrosoftAuthentication fma = FlutterMicrosoftAuthentication(
kClientID: "<client-id>",
kAuthority: "https://login.microsoftonline.com/organizations",
kScopes: ["User.Read", "User.ReadBasic.All"],
androidConfigAssetPath: "assets/auth_config.json"
);
String authToken = await this.fma.acquireTokenInteractively;
String authToken = await this.fma.acquireTokenSilently;
await this.fma.signOut;
await this.fma.loadAccount;