-
Notifications
You must be signed in to change notification settings - Fork 204
Description
Fix: Android build fails due to deprecated Gradle plugin configuration
Description
The Android build is currently failing, preventing the app from being run or compiled on Android devices and emulators. This is blocking all Android development work.
Environment
- Platform: Android
- Build command:
flutter run(debug mode) - Build target:
sdk gphone64 arm64emulator
Error Details
Attempting to build the app for Android results in an immediate Gradle failure during the configuration phase:
Launching lib/main.dart on sdk gphone64 arm64 in debug mode...
FAILURE: Build failed with an exception.
* Where:
Script '/Users/chandragupt/develop/flutter/packages/flutter_tools/gradle/app_plugin_loader.gradle' line: 9
* What went wrong:
A problem occurred evaluating script.
> You are applying Flutter's app_plugin_loader Gradle plugin imperatively using the apply script method, which is not possible anymore. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/to/flutter-gradle-plugin-apply
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
BUILD FAILED in 1s
Running Gradle task 'assembleDebug'... 2,014ms
Error: Gradle task assembleDebug failed with exit code 1
Root Cause Analysis
The project is using the deprecated imperative apply script method for loading Flutter's Gradle plugin. This approach was valid in older Flutter/Gradle versions but has been removed in favor of the modern declarative approach.
Key issues identified:
- Outdated plugin application method: The
android/settings.gradlefile is likely usingapply from:statements to load Flutter plugins imperatively - Build system version mismatch: Our current Gradle wrapper, Kotlin version, and Android Gradle Plugin (AGP) versions are likely incompatible with the latest Flutter SDK requirements
- Deprecated configuration patterns: The overall Android build configuration predates current Flutter best practices
The error message explicitly directs us to Flutter's migration guide, confirming this is a known breaking change that requires manual intervention.
Proposed Solution
Phase 1: Build System Modernization
- Migrate
android/settings.gradleto use the declarativeplugins {}block as per Flutter's migration guide - Update
android/build.gradle(project-level) to use modern plugin DSL - Update
android/app/build.gradle(app-level) for compatibility - Bump Gradle wrapper to a current stable version (likely 7.x or 8.x)
- Update Kotlin version to match Gradle requirements
- Update Android Gradle Plugin (AGP) to a compatible version
- Update
compileSdkVersion,targetSdkVersion, andminSdkVersionas needed
Phase 2: Verification
- Test build on multiple Android API levels
- Verify both debug and release build configurations
- Confirm hot reload and hot restart functionality
Expected Impact & Dependencies
Modernizing the core build system will have cascading effects across the project:
Package Updates Required
- Many Flutter packages in
pubspec.yamlwill need version updates to maintain compatibility with the modernized build environment - Packages with native Android code may require specific minimum versions
- Current dependency versions may be incompatible with updated Gradle/Kotlin versions
Potential Breaking Changes
google_sign_in: This package has undergone significant API changes in recent versions. The current implementation may need refactoring to use the new authentication flow- Other platform packages: Any packages with platform-specific code may have deprecated APIs that need updating
- Build configuration: Custom Gradle configuration or third-party plugin integrations may need adjustment
Benefits
- Brings the project into compliance with current Flutter standards
- Enables use of modern Gradle features and optimizations
- Improves build performance and developer experience
- Positions the project for future Flutter SDK updates
- Reduces technical debt
Priority
High - This is a blocking issue preventing all Android development. No Android builds can be completed until this is resolved.
Screenshots

