Install, build and debug a flutter app in WSL2 (Windows Subsystem for Linux).
To install the JDK, execute the following command, which will also install the JRE:
sudo apt install default-jdk
Add the following two lines to /etc/profile
(setting the JAVA_HOME
environment variable):
export JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"
export PATH="$JAVA_HOME/bin:$PATH"
Open a new terminal window to automatically source the file.
For Linux desktop development, you need the following in addition to the Flutter SDK:
sudo apt install clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev
Refer to Microsoft's instructions below.
- Create a
Downloads
directory if it doesn’t already exist, and navigate to it.
mkdir -p $HOME/Downloads && cd "$_"
- Download the latest stable release of the Flutter SDK (Right-click and select “Copy link” to copy the address of the archive.):
wget https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.7.9-stable.tar.xz
- Create an
Applications
directory if it doesn’t already exist, and navigate to it.
mkdir -p $HOME/Applications && cd "$_"
- Extract the Flutter files from the archive in the
Downloads
directory to theApplications
directory.
tar xfv $HOME/Downloads/$(ls -d $HOME/Downloads/flutter*.tar.xz | xargs basename)
Run the following command to see if there are any dependencies you need to install to complete the setup (for verbose output, add the -v flag):
flutter doctor
Add the following line to .bashrc
:
export PATH="$HOME/Applications/flutter/bin:$PATH"
Open a new terminal window to automatically source the file (or run source .bashrc
)
flutter doctor --android-licenses
thank you namnguyen02!!