-
Notifications
You must be signed in to change notification settings - Fork 3
MobileClientSetupGuide
Setting up Flutter, - and to be more precise - the Android SDK and an Android Emulator is a pain the ass. Hence/Consequently, I decided to compose a simple setup guide for Flutter and the Android SDK - as well as an Android Emulator to accompany the latter -, to make setup more practical.
git clone https://github.com/Koukobin/Ermis.gitsudo apt update
sudo apt upgrade
sudo apt-get update -y && sudo apt-get upgrade -y;
sudo apt-get install -y curl git unzip xz-utils zip libglu1-mesa
sudo apt-get install libc6:amd64 libstdc++6:amd64 lib32z1 libbz2-1.0:amd64
cd /opt/
sudo wget https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.29.0-stable.tar.xz
sudo tar xf flutter_linux_3.29.0-stable.tar.xz
sudo rm -r flutter_linux_3.29.0-stable.tar.xz
# Subsequently add Flutter to the Bash PATH
echo '' >> ~/.bashrc
echo '' >> ~/.bashrc
echo '# Flutter' >> ~/.bashrc
echo 'export PATH=/opt/flutter/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
sudo chown -R $(whoami):$(whoami) /opt/flutter
flutter --version
flutter doctor
# Optional: configure for Linux app development
sudo apt install clang
sudo apt install ninja-build
apt install cmake
apt install libgtk-3-devOptional: Upgrade Flutter to latest version:
flutter upgradeNote: If you encounter the following error:
/usr/bin/env: ‘bash\r’: No such file or directoryRun these commands to fix it using
dos2unix:sudo apt install dos2unix dos2unix /opt/flutter/bin/flutter find /opt/flutter/bin -type f -exec dos2unix {} +Alternatively, if you don't want to install or use
dos2unix, run:sed -i 's/\r$//' /opt/flutter/bin/flutter find /opt/flutter/bin -type f -exec sed -i 's/\r$//' {} +
Download the Android SDK Command-Line Tools.
Tip
You can download the latest version of the Android SDK Command-Line Tools from the official Android Developer website:
- Go to Android SDK Downloads (https://developer.android.com/studio).
- Scroll down to the "Command line tools only" section and download the appropriate version for Linux.
mkdir -p ~/Android/Sdk/
mv ~/Downloads/`commandlinetools-linux-NUMBER_latest.zip` Android/Sdk/
# Add Android SDK to Bash PATH
echo '' >> ~/.bashrc
echo '' >> ~/.bashrc
echo '# Android SDK' >> ~/.bashrc
echo 'export ANDROID_HOME=$HOME/Android/Sdk' >> ~/.bashrc
echo 'export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin' >> ~/.bashrc
echo 'export PATH=$HOME/Android/Sdk/emulator:$PATH' >> ~/.bashrc
source ~/.bashrc
# Hover to $ANDROID_HOME folder and extract the `cmdline-tools` zip file
cd $ANDROID_HOME/
unzip `commandlinetools-linux-NUMBER_latest.zip`
# Hover to `cmdline-tools` directory, and proceed with moving all contents into a 'latest' subfolder,
# which is essential for the Android SDK to correctly locate and use the command-line tools (Ι truly
# want to know what luminary university graduate came up with this prerequisite).
cd cmdline-tools
mkdir latest
shopt -s extglob # Enable extended globbing
mv !(latest) latest/ # Move everything into `latest` excluding itself
shopt -u extglob # Optionally disable extended globbing afterwardssdkmanager "emulator"
sdkmanager "platform-tools"
sdkmanager "tools"
sdkmanager "platforms;android-35"
sdkmanager "system-images;android-35;google_apis;x86_64"
avdmanager create avd -n Android_15_Emulator -k "system-images;android-35;google_apis;x86_64" --device "pixel"emulator -avd Android_15_EmulatorOR (Personally, I have found that the following command yields better overall performance and responsiveness)
emulator -avd Android_15_Emulator -no-snapshot-load -no-boot-anim -gpu host -memory 4096 -accel onNavigate to the top of the flutter project and execute the following from the command line:
# First execute `./build.sh` to ensure built is updated correctly.
./build.sh
# Finally, start app
flutter run"Arguing that you don’t care about the right to privacy because you have nothing to hide is no different than saying you don’t care about free speech because you have nothing to say"
— Dr. Edward Snowden