You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter升级至1.2后真机启动报致命异常的解决方法

Fix: Flutter 1.2 Upgrade Crash - ClassNotFoundException for io.flutter.app.FlutterApplication

Hey there, sorry to hear you're hitting this crash after upgrading to Flutter 1.2. The error points to a missing FlutterApplication class in your APK's Dex path, which usually stems from misaligned Android configuration post-upgrade. Let's walk through the fixes one by one:

1. Verify AndroidManifest.xml Configuration

First, check your app's Android manifest to ensure the application class is correctly set. Open android/app/src/main/AndroidManifest.xml and look at the root <application> tag:

If it’s set to android:name="io.flutter.app.FlutterApplication", try temporarily replacing it with the Android MultiDex application class to rule out Dex-related issues:

<application
    android:name="android.support.multidex.MultiDexApplication"
    <!-- keep your other existing attributes -->
    ...>

If you have a custom Application class, make sure it extends MultiDexApplication instead of the default Application.

2. Enable MultiDex in Gradle

Flutter upgrades can sometimes push your app's method count beyond Android's 64k Dex limit, triggering this error. Enable MultiDex support in your app's build config:
Open android/app/build.gradle and update these sections:

android {
    defaultConfig {
        // Add this line to enable MultiDex
        multiDexEnabled true
        // ... your existing config (minSdkVersion, targetSdkVersion, etc.)
    }
}

dependencies {
    // Add the MultiDex dependency
    implementation 'com.android.support:multidex:1.0.3'
}

3. Clean and Rebuild Thoroughly

You’ve already run basic clean commands, but let’s do a deep clean of cached build artifacts to eliminate any leftover conflicts:

  • Run flutter clean again
  • Manually delete the android/.gradle and android/app/build directories
  • Run flutter pub get to refresh dependencies
  • Finally, deploy to your device with flutter run

4. Validate Flutter SDK and Android Tooling

Run flutter doctor in your terminal to check for misconfigured Android dependencies. Look out for warnings about:

  • Outdated Android SDK components
  • Mismatched Gradle plugin versions
  • Missing build tools

Follow the prompts from flutter doctor to fix any flagged issues (e.g., updating SDK components or Gradle).

5. Uninstall and Reinstall the App

Old app remnants on your device can sometimes cause conflicts. Uninstall the existing version completely, clear any leftover app cache, then deploy the newly built APK with flutter run.

These steps should resolve the ClassNotFoundException by ensuring the Flutter application class is properly included in your Dex files and all dependencies are aligned with Flutter 1.2.

内容的提问来源于stack exchange,提问作者oryan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 18:47:47