Skip to content

Adding an external native build to an Android project using ndk-build results in "more than one externalNativeBuild path specified" error #175968

Closed

Description

@TheLastBanana

Steps to reproduce

  1. Create a new Flutter project for Android using flutter create ndk_build_sample --platforms=android.
  2. In android/app/build.gradle.kts file, add an external native build using ndk-build:
externalNativeBuild {
  ndkBuild {
      path = file("src/main/cpp/Android.mk") // This can point to an empty file for repro purposes
  }
}
  1. In Android Studio, click on "Sync Project With Gradle Files".

Expected results

The Gradle sync succeeds, and the ndk-build file is included in the build process as expected.
Alternatively, if ndk-build is not supported in Flutter apps, this should produce a clearer error.

Actual results

Gradle configuration fails for :app with the following error:

> Configure project :app
[CXX1400] More than one externalNativeBuild path specified
[CXX1400] More than one externalNativeBuild path specified
[CXX1400] More than one externalNativeBuild path specified

Code sample

Sample project: https://github.com/TheLastBanana/ndk_build_sample

Screenshots or Video

No response

Logs

No response

Flutter Doctor output

Doctor output
[√] Flutter (Channel stable, 3.35.4, on Microsoft Windows [Version 10.0.26100.6584], locale en-CA) [279ms]
    • Flutter version 3.35.4 on channel stable at G:\flutter_3.35.x
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d693b4b9db (8 days ago), 2025-09-16 14:27:41 +0000
    • Engine revision c298091351
    • Dart version 3.9.2
    • DevTools version 2.48.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android,
      enable-ios, cli-animations, enable-lldb-debugging

[√] Windows Version (Windows 11 or higher, 24H2, 2009) [795ms]

[√] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [2.5s]
    • Android SDK at E:\Android\Sdk
    • Emulator version 36.1.9.0 (build_id 13823996) (CL:N/A)
    • Platform android-36, build-tools 36.0.0
    • Java binary at: E:\Program Files\Android\Android Studio\jbr\bin\java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.7+-13880790-b1038.58)
    • All Android licenses accepted.

[√] Chrome - develop for the web [95ms]
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.14.10) [94ms]
    • Visual Studio at E:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.14.36327.8
    • Windows 10 SDK version 10.0.26100.0

[√] Android Studio (version 2025.1.3) [12ms]
    • Android Studio at E:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.7+-13880790-b1038.58)

[√] Connected device (3 available) [150ms]
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.26100.6584]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 140.0.7339.128
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 140.0.3485.81

[√] Network resources [593ms]
    • All expected network resources are available.

• No issues found!

Activity

  1. TheLastBanana commented on Sep 24, 2025

    @TheLastBanana
    Author

    If I comment out the call to FlutterPluginUtils.forceNdkDownload in FlutterPlugin.apply, the app builds as expected. It looks like that function has an early out if the project has an existing CMake build, but if the project uses ndk-build, it adds the extra build anyway, leading to multiple external native builds.

  2. darshankawar commented on Sep 25, 2025

    @darshankawar
    Member

    Thanks for the report. I was able to replicate the reported behavior on latest stable and master versions which throws below error upon running ./gradlew sync inside android folder:

    FAILURE: Build failed with an exception.
    
    * Where:
    Build file '/Users/dhs/Documents/NCFlutter/foo/android/build.gradle.kts' line: 19
    
    * What went wrong:
    A problem occurred configuring project ':app'.
    > [CXX1400] More than one externalNativeBuild path specified
    
    * 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 42s
    4 actionable tasks: 1 executed, 3 up-to-date
    dhs@Dhss-MacBook-Pro android % 
    
    
    stable : 3.35.4
    master : 3.37.0-1.0.pre-255
    
  3. added
    platform-androidAndroid applications specifically
    team-androidOwned by Android platform team
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    t: gradle"flutter build" and "flutter run" on Android
    toolAffects the "flutter" command-line tool. See also t: labels.
    and removed
    in triagePresently being triaged by the triage team
    on Sep 25, 2025
  4. added
    P2Important issues not at the top of the work list
    triaged-androidTriaged by Android platform team
    on Sep 30, 2025
  5. removed
    P2Important issues not at the top of the work list
    on Sep 30, 2025
  6. 1 remaining item

  7. gmackall commented on Oct 1, 2025

    @gmackall
    Member

    It looks like unfortunately the configuration we use to make AGP download the NDK conflicts with your ndk-build config, because AGP doesn't allow mixing ndk-build and cmake
    https://issuetracker.google.com/issues/120166563

    We will need to find a way to make this configuration happen late enough in Gradle's lifecycle that we can detect if the user is configuring either ndk-build or cmake, or otherwise provide a flag to disable the configuration we are doing in forceNdkDownload
    https://github.com/flutter/flutter/blob/master/packages/flutter_tools/gradle/src/main/kotlin/FlutterPluginUtils.kt#L588

  8. added
    ⏳Bot is counting down the days until it unassigns the issue
    on Feb 5, 2026
  9. flutter-triage-bot commented on Feb 5, 2026

    @flutter-triage-bot

    This issue is assigned to @gmackall but has had no recent status updates. Please consider unassigning this issue if it is not going to be addressed in the near future. This allows people to have a clearer picture of what work is actually planned. Thanks!

  10. flutter-triage-bot commented on Apr 22, 2026

    @flutter-triage-bot

    This issue was assigned to @gmackall but has had no status updates in a long time. To remove any ambiguity about whether the issue is being worked on, the assignee was removed.

  11. removed
    ⏳Bot is counting down the days until it unassigns the issue
    on Apr 22, 2026
  12. added
    P2Important issues not at the top of the work list
    triaged-androidTriaged by Android platform team
    and removed
    P1High-priority issues at the top of the work list
    on Apr 28, 2026
  13. added a commit that references this issue on May 14, 2026
  14. added a commit that references this issue on Jul 23, 2026
    2deea74
  15. github-actions commented on Aug 6, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  16. locked as resolved and limited conversation to collaborators on Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfound in release: 3.35Found to occur in 3.35found in release: 3.37Found to occur in 3.37has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyt: gradle"flutter build" and "flutter run" on Androidteam-androidOwned by Android platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions