Skip to content

fix(android): pickFirsts libc++_shared.so to unblock multi-plugin Flet apps#6571

Open
ndonkoHenri wants to merge 6 commits into
flet-0.86from
fix-android-libcpp
Open

fix(android): pickFirsts libc++_shared.so to unblock multi-plugin Flet apps#6571
ndonkoHenri wants to merge 6 commits into
flet-0.86from
fix-android-libcpp

Conversation

@ndonkoHenri

@ndonkoHenri ndonkoHenri commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Resolves #6570flet build apk / flet debug android fails at mergeDebugNativeLibs with N files found with path 'lib/<abi>/libc++_shared.so' whenever an app combines serious_python_android (Flet's Python runtime — bundles libc++_shared.so because the pypi.flet.dev wheels link against it) with any third-party Flutter plugin that also ships its own copy (e.g. ultralytics_yolo, sentry_flutter, several ML / CV / audio plugins).

Adds pickFirsts += listOf("**/libc++_shared.so") to the existing packaging.jniLibs { } block in the generated android/app/build.gradle.kts. AGP then picks whichever copy wins input ordering and discards the rest. Safe specifically here because the NDK has held strict ABI compatibility on libc++_shared.so since r17 — any consumer that linked against it works against any version. The glob is narrowly scoped, so any other future duplicate-native-lib clash still fails loudly rather than getting silently masked.

Also catches up on missing release-notes links: 0.85.2, 0.85.3, 0.85.4 (new), plus 0.1.46 and 0.1.53 (older entries that were skipped because their CHANGELOG headings are linkified).

Summary by Sourcery

Resolve Android APK build failures caused by duplicate libc++_shared.so when combining the Flet Python runtime with certain Flutter plugins, and update release notes links for recent and older versions.

Bug Fixes:

  • Ensure generated Android Gradle config picks a single libc++_shared.so when multiple plugins bundle the NDK C++ runtime, preventing mergeDebugNativeLibs failures.

Documentation:

  • Add changelog entry for version 0.85.4 describing the Android build fix.
  • Update website release-notes page with links for versions 0.85.4, 0.85.3, 0.85.2, 0.1.53, and 0.1.46.

…t apps

Gradle's mergeNativeLibs task aborts when more than one input
contributes a file at the same path. serious_python_android (the
Python runtime shipped via mobile-forge wheels) bundles
libc++_shared.so because cross-compiled wheels link against it;
many third-party Flutter plugins (ultralytics_yolo, sentry_flutter,
several ML/CV/audio plugins) ship their own copy too. The clash
surfaces as

    > N files found with path 'lib/<abi>/libc++_shared.so' from inputs:
        - .../<plugin_a>/.../libc++_shared.so
        - .../serious_python_android/.../libc++_shared.so

and breaks any Flet app that combines flet-libcpp-shared-backed
wheels with a third-party plugin that also bundles libc++_shared.so
(reported in #6570 for a YOLO + opencv-python app).

libc++_shared.so is the NDK's shared C++ runtime, and the NDK has
held strict ABI compatibility on it since r17 (June 2018). Whichever
copy wins Gradle's input ordering, every consumer that linked
against libc++_shared will work against it -- which makes pickFirsts
the documented, narrowly-scoped escape hatch for this specific
collision. The directive is glob-scoped to **/libc++_shared.so so
any other future duplicate-native-lib clash still fails loudly
rather than getting silently masked.

Resolves the runtime crash / build failure in #6570; verified
working by the reporter via a local one-line edit before this
landed.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We've reviewed this pull request using the Sourcery rules engine

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 11, 2026

Copy link
Copy Markdown

Deploying flet-website-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 88af648
Status:🚫  Build failed.

View logs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR unblocks Android builds for multi-plugin Flet apps by adjusting the generated Android Gradle template to resolve duplicate libc++_shared.so conflicts during mergeDebugNativeLibs, and it updates the website release-notes index to link to missing changelog sections.

Changes:

  • Add packaging.jniLibs.pickFirsts for **/libc++_shared.so in the generated android/app/build.gradle.kts to avoid duplicate-native-lib merge failures.
  • Add a 0.85.4 changelog entry describing the Android build fix.
  • Add missing release-notes links for 0.85.4, 0.85.3, 0.85.2, 0.1.53, and 0.1.46.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
sdk/python/templates/build/{{cookiecutter.out_dir}}/android/app/build.gradle.kts Adds a narrowly-scoped pickFirsts rule to prevent Gradle native lib merge failures from duplicate libc++_shared.so.
CHANGELOG.md Documents the new 0.85.4 bug fix entry for the Android packaging change.
website/docs/updates/release-notes.md Adds missing links to the relevant changelog anchors for recently added and previously skipped versions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ndonkoHenri ndonkoHenri changed the base branch from main to flet-0.86 June 11, 2026 21:33
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.

bug: flet build apk opencv-python Encountered an error, Failed to package successfully

2 participants