---
title: "Viewer widget 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-07-03T00:00:00.000Z"
description: "Solutions for the viewer widget AppCompatActivity issue in Nutrient Flutter SDK, with debugging tips and workarounds."
---

The Nutrient viewer widgets for Flutter, `NutrientDocumentView` and the legacy `NutrientView`, require the activity in your Flutter Android project to extend `AppCompatActivity`. Stock Flutter `Activity` implementations don’t extend `AppCompatActivity`, so the viewer can crash when your app starts:

```

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

```

To fix this, point your launcher activity to `NutrientFlutterActivity`, which `nutrient_flutter_android` provides. For setup details, refer to the [getting started](https://www.nutrient.io/sdk/flutter/getting-started.md) guide.

Alternatively, make your activity extend the `FlutterAppCompatActivity` implementation. If your dependencies don’t include `androidx.appcompat:appcompat`, you might see compile errors. Add the following line under `dependencies` in `android/app/build.gradle`, and replace `$appcompat_version` with a real version:

```kotlin

implementation "androidx.appcompat:appcompat:$appcompat_version"

```

If your app’s theme isn’t based on `AppCompat`, `FlutterAppCompatActivity` can cause another error:

```

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.

```

To fix this, change your Android project’s main theme parent to an `AppCompat`-based theme, such as `PSPDFKit.Theme.Default`. Open `/android/app/src/main/res/values/styles.xml` and make the following change:

```xml

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

```

For dark mode support, set the parent theme in `values-night/styles.xml`, such as `PSPDFKit.Theme.Dark`. Open `/android/app/src/main/res/values-night/styles.xml` and make the following change:

```xml

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

```

If you don’t update the night mode theme, the app will crash 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

- [Troubleshooting](/guides/flutter/troubleshooting.md)
- [How to add the license key for your Flutter app](/guides/flutter/troubleshooting/add-license-key.md)
- [Cocoapods Conflicts With Asdf](/guides/flutter/troubleshooting/cocoapods-conflicts-with-asdf.md)
- [How to find your iOS app bundle ID quickly](/guides/flutter/troubleshooting/finding-the-bundle-id.md)
- [Flutter Configuration Problems](/guides/flutter/troubleshooting/flutter-configuration-problems.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)
- [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)
- [Understanding bundle IDs for iOS app development](/guides/flutter/troubleshooting/what-is-a-bundle-id.md)
- [What Is An App Id](/guides/flutter/troubleshooting/what-is-an-app-id.md)

