Skip to content

Instantly share code, notes, and snippets.

@yordanoweb
Last active June 15, 2022 18:55
Show Gist options
  • Save yordanoweb/802c54c3607a78021e4888949e91a214 to your computer and use it in GitHub Desktop.
Save yordanoweb/802c54c3607a78021e4888949e91a214 to your computer and use it in GitHub Desktop.
Create Flutter project without Android Studio in ArchLinux

Install packages

sudo pacman -S flutter dart kotlin android-sdk android-sdk-platform-tools android-sdk-build-tools \
               android-platform android-sdk-cmdline-tools-latest jdk17-openjdk

Note: The required JDK must be higher than 11.

Set required environment variables

Put them in .bashrc, .zshrc or any other shell init script:

export ANDROID_SDK_ROOT=/opt/android-sdk
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools/
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin/
export PATH=$PATH:$ANDROID_ROOT/emulator
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/

Restart your shell session. Close terminal and open again.

If you have multiple JDKs

export JAVA_HOME=/usr/lib/jvm/java-17-openjdk

Note: The JDK version could be different at the time you use this info.

If you have chrome installed (not required)

export CHROME_EXECUTABLE=/opt/google/chrome/chrome

If you need socks proxy for gradle

Modify /path/to/project/android/gradle.properties

org.gradle.jvmargs=--DsocksProxyHost=127.0.0.1 -DsocksProxyPort=9050

Then, start the tor service or any socks proxy that you prefer.

Execute a first apk build

cd /path/to/project/
flutter -vv build apk

This will download all required dependencies the first time. It will take a long time, specially on slow Internet connection.

Disconnect from Internet for subsequent builds

Create init.gradle at ~/.gradle and put in it:

startParameter.offline=false

Then, you can build the project without depending on the Internet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment