Ref: https://docs.flutter.dev/get-started/install/linux/android
Development tools
To develop Flutter on Linux:
1. Verify that you have the following tools installed: bash, file, mkdir, rm, which
|
1 2 3 4 5 6 |
satria@teddy:~$ which bash file mkdir rm which /usr/bin/bash /usr/bin/file /usr/bin/mkdir /usr/bin/rm /usr/bin/which |
2. Install the following packages: curl, git, unzip, xz-utils, zip, libglu1-mesa
|
1 2 |
satria@teddy:~$ sudo apt-get update -y && sudo apt-get upgrade -y satria@teddy:~$ sudo apt-get install -y curl git unzip xz-utils zip libglu1-mesa |
3. To develop Android apps:
a. Install the following prerequisite packages for Android Studio.
|
1 2 3 |
satria@teddy:~$ sudo apt-get install \ libc6:amd64 libstdc++6:amd64 \ libbz2-1.0:amd64 libncurses5:amd64 |
b. Install Android Studio 2023.3.1 (Jellyfish) or later to debug and compile Java or Kotlin code for Android. Flutter requires the full version of Android Studio.
download and install the latest android studio from https://developer.android.com/studio
If you are running a 64-bit version of Ubuntu, you need to install some 32-bit libraries with the following command:
|
1 |
satria@teddy:~$ sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386 |
read the installation note on https://developer.android.com/studio/install#linux
Extract the downloaded file:
|
1 2 |
satria@teddy:~$ cd Downloads/ satria@teddy:~/Downloads$ tar -xvzf android-studio-*-linux.tar.gz |
Move to the android-studio directory:
|
1 |
satria@teddy:~/Downloads$ sudo mv android-studio /opt/ |
Run Android Studio:
Navigate to the bin directory and run the installer:
|
1 2 |
satria@teddy:~/Downloads$ cd /opt/android-studio/bin/ satria@teddy:/opt/android-studio/bin$ ./studio.sh |
Use VS Code to install Flutter
To install Flutter using these instructions, verify that you have installed Visual Studio Code 1.77 or later and the Flutter extension for VS Code.
Prompt VS Code to install Flutter
#
Launch VS Code.
To open the Command Palette, press Control + Shift + P.
In the Command Palette, type flutter.
Select Flutter: New Project.
VS Code prompts you to locate the Flutter SDK on your computer.
If you have the Flutter SDK installed, click Locate SDK.
If you do not have the Flutter SDK installed, click Download SDK.
This option sends you the Flutter install page if you have not installed Git as directed in the development tools prerequisites.
When prompted Which Flutter template?, ignore it. Press Esc. You can create a test project after checking your development setup.
INSTALL CMAKE (ALSO FOR LINUX APP)
sudo apt install cmake
Launching lib/main.dart on Linux in debug mode…
CMake Error: CMake was unable to find a build program corresponding to “Ninja”. CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
Error: Unable to generate build files
INSTALL NINJA BUILD
sudo apt install ninja-build
Launching lib/main.dart on Linux in debug mode…
CMake Error at /usr/share/cmake-3.22/Modules/CMakeDetermineCXXCompiler.cmake:48 (message):
Could not find compiler set in environment variable CXX:
clang++.
Call Stack (most recent call first):
CMakeLists.txt:3 (project)
2
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
Error: Unable to generate build files
ALSO
satria@teddy:/opt/android-studio/bin$ sudo apt-get install \
clang cmake git \
ninja-build pkg-config \
libgtk-3-dev liblzma-dev \
libstdc++-12-dev
BUT GOT
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
... Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: libcairo2-dev : Depends: libfontconfig1-dev (>= 2.2.95) Depends: libfreetype6-dev (>= 2.1.10) libgtk-3-dev : Depends: libfontconfig1-dev libharfbuzz-dev : Depends: libfreetype6-dev libpango1.0-dev : Depends: libfontconfig-dev (>= 2.13.0) but it is not installable Depends: libfreetype-dev (>= 2.1.7) but it is not installable libxft-dev : Depends: libfontconfig1-dev Depends: libfreetype6-dev E: Unable to correct problems, you have held broken packages. |
libbrotli-dev : Depends: libbrotli1 (= 1.0.9-2build6)
SOLUTION:
|
1 |
sudo apt install libbrotli1=1.0.9-2build6 libfreetype6-dev libfontconfig1-dev libfreetype6-dev libcairo2-dev libgtk-3-dev libharfbuzz-dev libpango1.0-dev libxft-dev |
THEN RE-RUN:
satria@teddy:/opt/android-studio/bin$ sudo apt-get install \
clang cmake git \
ninja-build pkg-config \
libgtk-3-dev liblzma-dev \
libstdc++-12-dev