Skip to content

Fix Android Flutter embedding resolution on newer SDKs#456

Open
cdeil wants to merge 1 commit intoultralytics:mainfrom
cdeil:fix/flutter-embedding-resolution
Open

Fix Android Flutter embedding resolution on newer SDKs#456
cdeil wants to merge 1 commit intoultralytics:mainfrom
cdeil:fix/flutter-embedding-resolution

Conversation

@cdeil
Copy link
Copy Markdown

@cdeil cdeil commented Mar 9, 2026

I ran into two Android build issues ( #455 and this one) today and the coding agent suggested that both are things that should be resolved in the ultralytics_yolo package itself.

cc @john-rocky since you added this build.gradle config ca a year ago.


Coding agent:

Summary

This removes the plugin's hard-coded Android flutter.jar lookup from android/build.gradle.

The current build script prefers legacy local SDK paths like bin/cache/artifacts/engine/android-arm/flutter.jar whenever flutter.sdk or FLUTTER_ROOT is set. Those paths are no longer present in newer Flutter SDKs such as Flutter 3.41.x, which causes Android builds to fail before the plugin can compile.

Modern Flutter plugin templates no longer declare these manual embedding dependencies. Letting Flutter and Gradle provide the embedding is the compatible path for current SDKs and avoids coupling the plugin to obsolete engine cache layouts.

Changes

  • remove the unused flutter.sdk and FLUTTER_ROOT lookup from the Android plugin Gradle file
  • remove the manual compileOnly files(.../flutter.jar) dependencies
  • remove the fallback hard-coded io.flutter:flutter_embedding_release coordinate

Note: example/android/ultralytics_yolo_plugin is a symlink to android, so the single tracked Gradle change covers both locations.

Validation

  • confirmed the issue on local Flutter 3.41.4, where the legacy android-arm/flutter.jar paths are absent
  • compared against a fresh Flutter 3.41.4 plugin template, which no longer declares explicit embedding dependencies
  • ran cd example && flutter build apk --debug
  • the build now gets past the stale flutter.jar resolution path and fails later on an unrelated Android Gradle Plugin metadata mismatch (AGP 8.6.0 vs dependencies requiring 8.9.1+)

Context

This addresses the second Android compatibility problem discussed alongside issue #455. The Java 17 toolchain requirement remains a separate issue.

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

🔧 Simplifies Android Gradle configuration to fix Flutter embedding resolution issues on newer SDK setups.

📊 Key Changes

  • Removed manual Flutter SDK path discovery from android/build.gradle using local.properties and FLUTTER_ROOT.
  • Removed conditional compileOnly references to architecture-specific flutter.jar files.
  • Removed fallback dependency on io.flutter:flutter_embedding_release.
  • Kept LiteRT and related Android dependencies unchanged.

🎯 Purpose & Impact

  • Fixes Android build compatibility on newer Flutter and SDK environments where older embedding resolution logic can fail.
  • Reduces Gradle complexity and avoids brittle SDK-specific path handling.
  • Improves maintainability by relying on the modern Flutter/Gradle integration instead of legacy embedding workarounds.
  • Helps contributors and CI environments build more reliably across updated Android toolchains.

@UltralyticsAssistant UltralyticsAssistant added bug Something isn't working dependencies Dependencies and packages fixed Bug has been resolved labels Mar 9, 2026
@UltralyticsAssistant
Copy link
Copy Markdown
Member

👋 Hello @cdeil, thank you for submitting a ultralytics/yolo-flutter-app 🚀 PR! This is an automated message to help with review readiness, and an engineer will assist you shortly 😊 Please review the checklist below to support a smooth integration:

  • Define a Purpose: Clearly explain the purpose of your fix or feature in your PR description, and link to any relevant issues. Ensure your commit messages are clear, concise, and adhere to the project's conventions.
  • Synchronize with Source: Confirm your PR is synchronized with the ultralytics/yolo-flutter-app main branch. If it's behind, update it by clicking the 'Update branch' button or by running git pull and git merge main locally.
  • Ensure CI Checks Pass: Verify all Ultralytics Continuous Integration (CI) checks are passing. If any checks fail, please address the issues.
  • Update Documentation: Update the relevant documentation for any new or modified features.
  • Add Tests: If applicable, include or update tests to cover your changes, and confirm that all tests are passing.
  • Sign the CLA: Please ensure you have signed our Contributor License Agreement if this is your first Ultralytics PR by writing "I have read the CLA Document and I sign the CLA" in a new message.
  • Minimize Changes: Limit your changes to the minimum necessary for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee

For more guidance, please refer to our Contributing Guide. Don't hesitate to leave a comment if you have any questions. Thank you for contributing to Ultralytics! 🚀

Copy link
Copy Markdown
Member

@UltralyticsAssistant UltralyticsAssistant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 PR Review

Made with ❤️ by Ultralytics Actions

The change looks clean based on the diff provided. Removing the legacy Flutter SDK path discovery and manual flutter.jar/embedding fallback logic is consistent with relying on modern Flutter Gradle integration, and I do not see a clear bug or regression in the changed lines alone.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cdeil
Copy link
Copy Markdown
Author

cdeil commented Apr 9, 2026

@pderrenger any chance to find a reviewer here and get this fixed?

@pderrenger
Copy link
Copy Markdown
Member

Thanks for the ping — I can’t promise review timing, but keeping this PR narrowly scoped with passing CI will help it move faster; see the contributing guide and CI docs for the current merge requirements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working dependencies Dependencies and packages fixed Bug has been resolved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants