Skip to content

[Bug]: build warning on Android for flatDir #8574

Open

Description

@HarelM

Capacitor Version

💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 8.5.0
@capacitor/core: 8.5.0
@capacitor/android: 8.5.0
@capacitor/ios: 8.5.0

Installed Dependencies:

@capacitor/core: 8.5.0
@capacitor/cli: 8.5.0
@capacitor/android: 8.5.0
@capacitor/ios: 8.5.0

[success] iOS looking great! 👌
[success] Android looking great! 👌

Other API Details

npm: 11.13.0
node: v24.16.0
pod: 1.16.2

Platforms Affected

  • iOS
  • Android
  • Web

Current Behavior

There's a warning about flatDir which I think can be easily solved.

Expected Behavior

No warning in the build

Project Reproduction

Any new capacitor project

Additional Information

You can find the two offending ones here:
https://github.com/search?q=repo%3Aionic-team%2Fcapacitor+flatdir&type=code)

They should be replaced with fileTree as far as I understand.

Activity

  1. added theissue type on Aug 18, 2026
  2. eric-horodyski commented on Oct 22, 2026

    @eric-horodyski
    Member

    Hi @HarelM, thanks for spotting this. We've identified this as a low priority and aren't looking to take it on anytime soon. However, we would be greatly appreciative if you—or another community member—would like to open a PR with these fixes.

  3. HarelM commented on Oct 25, 2026

    @HarelM
    Author

    To be honest, this was opened two month ago and only now I got a response.
    So I'm not very thrilled to open a PR that will sit and wait for a review...
    I personally solved this on my end by removing the cordova bridge plugin since I no longer use any cordova plugins, but that might not be a proper solution to other users.
    I'm guessing you could send a short AI prompt to solve this, similar to what I would do if I needed to open a PR.
    If by opening a PR it would help from a "required review" perspective I can help out...

  4. DevShoaib78 commented on Nov 7, 2026

    @DevShoaib78

    Hi, I'd like to pick this up, but I want to check the approach with you first, because a plain swap to fileTree would break some Cordova plugins.

    The flatDir entries are there for Cordova plugins that ship .aar files. cap sync copies those into capacitor-cordova-android-plugins/src/main/libs, and some plugins reference them by name (implementation(name: 'foo', ext: 'aar')), which only resolves through a flatDir in both that module and the app. That's why it was kept in #5287.

    What I'd suggest, so nobody breaks:

    1. Remove the flatDir blocks from the two templates (android-template/app/build.gradle and capacitor-cordova-android-plugins/build.gradle).
    2. In cap sync, add them back only when an installed Cordova plugin actually puts files into src/main/libs: in the plugins module's build.gradle (the CLI already regenerates that module on every sync) and in app/capacitor.build.gradle, which the CLI also regenerates and the app already applies.

    New apps without such plugins would build with no warning. Apps with them keep working, because the repository is still there when it's needed. Existing apps keep their current app/build.gradle, so nothing changes for them unless they remove the block themselves.

    I'd test it with a fresh app and with a Cordova plugin that ships an .aar before opening the PR. Would you take a PR like this against main, or would you rather keep it for the next major on next?

  5. aFeruz commented on Dec 4, 2026

    @aFeruz

    Hi @DevShoaib78, are you still working on this? If you've moved on, I'd be happy to pick it up using the approach you outlined (drop flatDir from the templates, and have cap sync add it back only when a Cordova plugin ships files into src/main/libs). Either way, I can help test on Linux + Android with a Cordova plugin that ships an .aar.

  6. aFeruz commented on Dec 4, 2026

    @aFeruz

    Quick update after testing on 9.0.0 (Linux, JDK 21, ./gradlew help --warning-mode all):

    So what's left is the second half of the approach above: emit flatDir only when a Cordova plugin actually copies files into src/main/libs.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    Fields

    Stage

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions