Flutter Installation Notes
1. Install Dependencies
Ensure you have the necessary dependencies installed:
sudo apt-get install -y curl git unzip xz-utils zip libglu1-mesa clang cmake ninja-build libgtk-3-dev
- Download Flutter SDK Download the latest stable version of Flutter:
tar -xf ~/Downloads/flutter_linux_3.27.4-stable.tar.xz -C ~/development/
- Update Path for Flutter Add Flutter to your system path by appending this line to your .bashrc (or .bash_profile):
echo 'export PATH="$HOME/development/flutter/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
- Check Flutter Doctor Run the following command to ensure Flutter is correctly installed:
flutter doctor
- Install Android SDK If you don't have Android SDK installed, you can install it:
sudo apt install android-sdk
- Install Command Line Tools Download and move Android command-line tools:
mv cmdline-tools/ ~/development/
mkdir -p ~/development/android-sdk/cmdline-tools
mv ~/development/cmdline-tools ~/development/android-sdk/cmdline-tools/latest
- Set ANDROID_HOME Path Add the following to .bashrc for the Android SDK:
echo 'export ANDROID_HOME=~/development/android-sdk' >> ~/.bashrc
source ~/.bashrc
- Install Required SDK Packages Run sdkmanager to install the necessary Android SDK components:
sdkmanager --install "cmdline-tools;latest" "platform-tools" "platforms;android-34" "build-tools;34.0.0"
- Accept Android Licenses To accept the Android SDK licenses, run:
flutter doctor --android-licenses
- Verify Setup Ensure everything is set up correctly by running:
flutter doctor
By following these steps, you'll have Flutter and Android SDK correctly installed and configured on your system.
Errors ==>
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/sdklib/tool/sdkmanager/SdkManagerCli has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:621)
- Reason is old java version
user:~/Desktop$ flutter doctor --android-licenses
Android sdkmanager not found. Update to the latest Android SDK and ensure that the cmdline-tools are installed to resolve this.
- Android sdk is not there.
- The error message git@github.com: Permission denied (publickey). indicates that your SSH key is either not set up or not added to GitHub. Follow these steps to fix it:
- Check if you have an SSH key Run:
ls -al ~/.ssh
If you see files like id_rsa and id_rsa.pub (or id_ed25519 and id_ed25519.pub), you have an SSH key. If not, you need to generate one.
- Generate an SSH Key (if missing) If you don’t have a key, generate one using:
ssh-keygen -t ed25519 -C "your-email@example.com"
Press Enter to accept the default location (~/.ssh/id_ed25519), then add a passphrase or leave it empty.
- Add SSH Key to GitHub Copy the public key:
cat ~/.ssh/id_ed25519.pub
Go to GitHub → Settings → SSH and GPG keys → New SSH Key, paste the copied key, and save.
- Add the SSH Key to SSH Agent Run:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
- Test SSH Connection Check if SSH works:
ssh -T git@github.com
If successful, it should say:
Hi user! You've successfully authenticated, but GitHub does not provide shell access.
- Retry Pushing the Code
git push --set-upstream origin master
Written by A.M. Rinas