flutterandroid-studio

I am having error in running my flutter project on my physical device


I am having this error in flutter project while running it on my physical device emulator.

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\Admin\AndroidStudioProjects\prac_proj\android\build.gradle.kts' line: 16

* What went wrong:
A problem occurred configuring project ':app'.
> [CXX1101] NDK at C:\Users\Admin\AppData\Local\Android\sdk\ndk\26.3.11579264 did not have a source.properties file

* 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 3s
Running Gradle task 'assembleDebug'...                              4.1s
Error: Gradle task assembleDebug failed with exit code 1

Solution

  • Based on my experience the issue is related to incomplete NDK download. You can try to delete the current NDK by going to android studio.

    Method # 1

    1. Go to SDK Manger > Android SDK > SDK Tools
    2. Enable "Show Package Details" (bottom-right corner).
    3. Locate the problematic NDK version (26.3.11579264) in the list.
    4. Uncheck it and click Apply to uninstall it.
    5. Once uninstalled:

    enter image description here

    Then check the show package details

    enter image description here

    Method # 2 Update the NDK Version in Your Project Configuration

    If you prefer to use a different, working version of the NDK:

    Open your project's build.gradle or build.gradle.kts file (depending on whether you're using Groovy or Kotlin). Locate the ndkVersion declaration. Replace it with a valid, installed version. For example:

       ndkVersion = "29.0.13113456"
    

    Note: NDK are backward compatible so installing latest version is a good approach. Also default project has

       ndkVersion = flutter.ndkVersion
    

    so you might have to manually enter your installed ndkVersion