Skip to main content

Linux Build failed with an exception

Estimated reading: 2 minutes

C++ Compilation Errors during Android ARM64 Build on Linux

You might encounter this kind of build error if your Flutter SDK is installed via snap.

See the image below

Image

If you encounter Build Errors during Android ARM64 Build on Linux then,

Follow these steps to resolve the compilation errors:

  • Download New Flutter SDK: Obtain the latest version of the Flutter SDK from the official Git repository. Click here to download Flutter SDK

  • Extract the downloaded SDK.

  • Update the system environment variables to include the path to the new Flutter SDK.
    How to Set Path to Environment in Linux

  • This ensures that the updated SDK is used during the build process.

  • Open your IDE
    If you are using Android Studio, then follow the steps below -

    • Go To File → Settings → Languages & Frameworks → Flutter

    • Check that your installed sdk is from snap or git

    • If your Flutter SDK path looks like this: './snap/flutter/common/flutter', then replace it with the Flutter SDK path that you downloaded from Git

      Image

After setting the path, attempt to rebuild the project to see if the compilation errors are resolved

Add Flutter SDK Path to System Environment in Linux

Follow these steps to add the Flutter SDK path to the system environment in Linux:

Step 1 - Open a terminal on your Linux system.

Step 2 - Locate Flutter SDK Path

Determine the path where you have extracted the Flutter SDK on your system.

Step 3 - Edit .bashrc or .bash_profile

Depending on your Linux distribution and configuration, you need to edit either the .bashrc or .bash_profile file in your home directory.
Use a text editor like nano or vim.

For example:

  nano ~/.bashrc  

or

  nano ~/.bash_profile  

Step 4 - Add Export Statement

Inside the file, add an export statement to set the PATH environment variable to include the Flutter SDK path.

For example:

  export PATH="$PATH:/path/to/flutter/bin"   

Replace /path/to/flutter with the actual path to your Flutter SDK directory.

Step 5 - Save and Close the File:

After adding the export statement, save the changes and close the text editor.

Step 6 - Reload .bashrc or .bash_profile:

To apply the changes immediately, you can either close and reopen the terminal or run the

following command:

  source ~/.bashrc

or

  source ~/.bash_profile

Step 7 - Verify Flutter SDK path

To verify that the Flutter SDK path has been added to the system environment, you can run:

  echo $PATH
```
This command will display the current value of the `PATH` environment variable, and you should see the Flutter SDK path included in the output.