---
title: "PspdfkitWidget AppCompatActivity issue"
canonical_url: "https://www.nutrient.io/guides/flutter/troubleshooting/pspdfkit-widget-appcompat-activity-issue/"
md_url: "https://www.nutrient.io/guides/flutter/troubleshooting/pspdfkit-widget-appcompat-activity-issue.md"
last_updated: "2026-05-23T00:08:18.095Z"
description: "Solutions for common issues and errors in Nutrient Flutter SDK with debugging tips and workarounds."
---

The `PspdfkitWidget` for Flutter requires the `MainActivity` in the Flutter Android project to extend `AppCompatActivity`, but currently, none of the available Flutter `Activity` implementations extend `AppCompatActivity`. This leads to a crash when you use it in your application:

```

java.lang.ClassCastException: com.example.app.MainActivity cannot be cast to androidx.appcompat.app.AppCompatActivity

```

You can fix this by extending our custom implementation of `FlutterAppCompatActivity` instead. You might see compile errors if `androidx.appcompat:appcompat` isn’t included in your dependencies, so make sure the `android/app/build.gradle` file has the line below under dependencies, and replace `$appcompat_version` with an actual version:

```kotlin

implementation "androidx.appcompat:appcompat:$appcompat_version"

```

Using `FlutterAppCompatActivity` also introduces another issue if your application’s theme isn’t `AppCompat` based:

```

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.activitylifecycletest/com.example.activitylifecycletest.DialogActivity}:
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

```

Fix this by changing your Android project’s main theme parent to an `AppCompat`-based theme. We recommend using `PSPDFKit.Theme.Default`.
Go to `/android/app/src/main/res/values/styles.xml` and make the following changes:

```xml

<style name="NormalTheme" parent="@style/PSPDFKit.Theme.Default">......
 </style>

```

For dark mode support, set the parent theme in the `values-night/styles.xml` file. We recommend using the `PSPDFKit.Theme.Dark` theme. Go to `/android/app/src/main/res/values-night/styles.xml` and make the following changes:

```xml

<style name="NormalTheme" parent="@style/PSPDFKit.Theme.Dark">......
 </style>

```

If the night mode theme isn’t updated, the app will crash when running on phones in dark mode. If your app doesn’t support dark mode, set the parent theme to `PSPDFKit.Theme.Default` for consistency.

---

## Related pages

- [How to add the license key for your Flutter app](/guides/flutter/troubleshooting/add-license-key.md)
- [How to find your current SDK version](/guides/flutter/troubleshooting/getting-the-currently-used-version.md)
- [Ios Flutter Platform Not Detected](/guides/flutter/troubleshooting/ios-flutter-platform-not-detected.md)
- [Measurement Magnifier Not Working On Android](/guides/flutter/troubleshooting/measurement-magnifier-not-working-on-android.md)
- [Flutter Configuration Problems](/guides/flutter/troubleshooting/flutter-configuration-problems.md)
- [Cocoapods Conflicts With Asdf](/guides/flutter/troubleshooting/cocoapods-conflicts-with-asdf.md)
- [Using Android Gradle Plugin 7](/guides/flutter/troubleshooting/using-android-gradle-plugin-7.md)
- [Manage status bar appearance in Flutter](/guides/flutter/troubleshooting/view-controller-based-status-bar-appearance.md)
- [How to find your iOS app bundle ID quickly](/guides/flutter/troubleshooting/finding-the-bundle-id.md)
- [What Is An App Id](/guides/flutter/troubleshooting/what-is-an-app-id.md)
- [Understanding bundle IDs for iOS app development](/guides/flutter/troubleshooting/what-is-a-bundle-id.md)

