Flutter升级后Gradle assembleDebug任务失败求助
registerResGeneratingTask is deprecated Error After Flutter Upgrade Hey there, let’s walk through actionable steps to fix this issue—you’re right to suspect outdated third-party plugins or AndroidX conflicts, since this error almost always stems from those areas post-Flutter upgrade.
1. Update All Third-Party Plugins First
Outdated plugins are the #1 culprit here, especially Firebase-related ones like cloud_firestore.
- Open your
pubspec.yamlfile and cross-check every plugin’s version against their latest stable releases. For Firebase packages, make sure you’re using versions compatible with your updated Flutter. - Run
flutter pub upgradeto pull the latest versions, thenflutter pub getto sync dependencies. - Follow up with
flutter cleanto wipe old build artifacts, then try rebuilding the app.
2. Double-Check AndroidX Configuration
Flutter upgrades often require full AndroidX compatibility, and missing setup here can clash with old plugins:
- Open
android/gradle.propertiesand confirm these lines are present (add them if missing):android.useAndroidX=true android.enableJetifier=true - Jetifier automatically converts old support library dependencies to AndroidX, which can resolve hidden conflicts from outdated plugins. After updating this file, run
flutter cleanand rebuild.
3. Align Gradle Versions with Your Flutter Update
New Flutter versions often require newer Gradle tooling. Mismatched versions can trigger deprecated method warnings:
- Open
android/build.gradleand update the Android Gradle plugin version to match Flutter’s recommended version (check Flutter’s docs for your specific release). For example:dependencies { classpath 'com.android.tools.build:gradle:7.4.2' // Use latest compatible version // Keep your Firebase Gradle plugin version aligned with Firebase SDKs too } - Update the Gradle wrapper in
android/gradle/wrapper/gradle-wrapper.properties:distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip - Make sure these versions are compatible with each other (the Gradle plugin and wrapper versions should pair correctly).
4. Pinpoint the Exact Offending Plugin
If updating plugins doesn’t work, find out which one is calling the deprecated method:
- Run
flutter run -vto get verbose build logs. Scan the output for the full context around theregisterResGeneratingTaskwarning—this will show which plugin’s code is triggering it. - Once you identify the plugin, check its GitHub issues to see if a fix is already available (maybe a beta version resolves the problem). If no fix exists, you might need to temporarily roll back the plugin to a version that works with your Flutter setup, or look for a alternative package.
5. Do a Full Clean Rebuild
Cached build files can hold onto old conflicts even after updates:
- Run
flutter cleanto delete all build artifacts. - Delete the
.gradlefolder inside your project’sandroiddirectory. - Run
flutter pub getagain, then launch the app withflutter run.
内容的提问来源于stack exchange,提问作者Jérémy

