Skip to content

Conversation

@meylis1998
Copy link

Summary

Fixes #239 - Resolves build failures when using Android Gradle Plugin (AGP) 8.x and newer Gradle versions.

Problem

Users were encountering compilation errors when building with flutter build apk --release:

error: package io.flutter.embedding.engine.plugins does not exist
error: package io.flutter.plugin.common does not exist

Root Cause

The Flutter declarative Gradle plugin fails to automatically add flutter.jar as a compile-time dependency to plugin modules when using AGP 8+. This is a known issue documented in flutter/flutter#177417.

Solution

This PR adds a compileOnly dependency on the Flutter embedding library (flutter.jar) that:

  • Dynamically locates the Flutter SDK from local.properties
  • Provides necessary Flutter framework classes at compile time
  • Doesn't bundle the library in the plugin output
  • Gracefully handles missing paths (backwards compatible)
  • Works with both imperative and declarative Gradle configurations

Changes

  • Modified app_links/android/build.gradle to add Flutter embedding dependency resolution

Testing

  • ✅ Tested with Flutter 3.38.5, AGP 8.11.1, Gradle 8.x
  • ✅ Example app builds successfully with flutter build apk --release
  • ✅ No compilation errors
  • flutter analyze passes

References

…ency

Fixes llfbandit#239

This commit resolves build failures when using Android Gradle Plugin (AGP) 8.x
and newer Gradle versions. Users were encountering compilation errors:
- "package io.flutter.embedding.engine.plugins does not exist"
- "package io.flutter.plugin.common does not exist"

Root cause:
The Flutter declarative Gradle plugin fails to automatically add flutter.jar
as a compile-time dependency to plugin modules when using AGP 8+.

Solution:
Added a compileOnly dependency on the Flutter embedding library (flutter.jar)
that dynamically locates the Flutter SDK from local.properties. This provides
the necessary Flutter framework classes at compile time without bundling them
in the plugin output.

The fix:
- Reads Flutter SDK path from local.properties
- Adds flutter.jar as compileOnly dependency
- Gracefully handles missing paths (backwards compatible)
- Works with both imperative and declarative Gradle configurations

References:
- flutter/flutter#177417
- llfbandit#239

Tested with:
- Flutter 3.38.5
- AGP 8.11.1
- Gradle 8.x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't build with latest AGP and gradle

1 participant