|
| 1 | +# flutter install step-by-step guide - Linux install (64 bit) |
| 2 | + |
| 3 | +## step 1 : Download the following installation bundles and tools to get started |
| 4 | + |
| 5 | +1. Get the Flutter SDK (latest stable version) - [Official flutter docs](https://flutter.dev/docs/get-started/install/linux#get-the-flutter-sdk) |
| 6 | +2. Get the Android Studio - [Download Android Studio](https://developer.android.com/studio) |
| 7 | + |
| 8 | +## step 2 : Create a workspace directory - this folder will contain all your projects, flutter sdk and all its dependencies. |
| 9 | + |
| 10 | +* Create a folder named "workspace" on your Desktop |
| 11 | +* Extract the files downloaded in step 1 |
| 12 | +* In your Downloads folder, To extract files, Right click on the file => Select "Extract Here" |
| 13 | +* Search for folders named "android-studio" & "flutter" in the above extracted folders. |
| 14 | +* Move "android-studio" & "flutter" folders into your "workspace" folder created on your Desktop. |
| 15 | + |
| 16 | +Note : By this stage your should have a "workspace" folder on your desktop which contains "android-studio" & "flutter" named folders. Now proceed to step 3 |
| 17 | + |
| 18 | +## step 3 : Install Android Studio in Linux (Ubuntu) |
| 19 | + |
| 20 | +Open Terminal, run command : |
| 21 | +``` |
| 22 | +$ cd Desktop/workspace/android-studio/bin |
| 23 | +$ ./studio.sh |
| 24 | +``` |
| 25 | +* ./studio.sh above command is used to run android studio setup wizard |
| 26 | +* Once the setup wizard is loaded |
| 27 | +* Select do not import settings |
| 28 | +* Click Next |
| 29 | +* Select Custom installation |
| 30 | +* Select the Dark theme |
| 31 | +* SDK Component Setup - Ensure you have tick mark on |
| 32 | +* Android SDK (component required) |
| 33 | +* Android Virtual Device (component required) |
| 34 | +* Select all other options as well to save time in future (Optional) |
| 35 | +* Now, create "Android" folder inside your workspace directory on your Desktop |
| 36 | +* Move the "Sdk" folder which is inside your workspace directory to newly created "Android" folder |
| 37 | +* Now, in the android studio wizard , set the sdk location |
| 38 | +* Android SDK Location = /home/dev/Desktop/workspace/Android/Sdk |
| 39 | +* Note : replace dev in the above sdk path with your username |
| 40 | +* Click on next twice and it will download the required files |
| 41 | +* Please check your connection. Internet Connection is required to download the files |
| 42 | +* Click on Finish once the download is completed |
| 43 | +* Close Android studio |
| 44 | + |
| 45 | +Note : This will create an Android folder in your workspace which will have Android SDK & also install Android Studio and AVD (Android Virtual Device) |
| 46 | + |
| 47 | +## step 4 : Update your PATH variable |
| 48 | + |
| 49 | +* Go to your HOME folder => Options => Show Hidden files |
| 50 | +* locate the .bashrc file in file explorer |
| 51 | +* Create a backup of the .bashrc file or .bash_profile file |
| 52 | +* Edit .bashrc file => Right click Open with text editor |
| 53 | + |
| 54 | +``` |
| 55 | +PATH=$PATH:/home/dev/Desktop/workspace/flutter/bin |
| 56 | +PATH=$PATH:/home/dev/Desktop/workspace/Android/Sdk |
| 57 | +PATH=$PATH:/home/dev/Desktop/workspace/Android/Sdk/tools |
| 58 | +PATH=$PATH:/home/dev/Desktop/workspace/Android/Sdk/platform-tools |
| 59 | +PATH=$PATH:/home/dev/Desktop/workspace/android-studio/bin |
| 60 | +``` |
| 61 | + |
| 62 | +* Add the above lines at the bottom of the .bashrc file |
| 63 | +* Click "Save" and exit the file. |
| 64 | +* Note : "dev" in the above path is username of our machine. Please replace "dev" inside above lines with your username |
| 65 | + |
| 66 | +### Explanation of the above lines that are added to the .bashrc file |
| 67 | + |
| 68 | +1. flutter bin environment variable |
| 69 | +``` |
| 70 | +PATH=$PATH:/home/dev/Desktop/workspace/flutter/bin |
| 71 | +``` |
| 72 | +Note : replace "dev" inside the above command with your username |
| 73 | + |
| 74 | +2. android sdk environment variables |
| 75 | +``` |
| 76 | +PATH=$PATH:/home/dev/Desktop/workspace/Android/Sdk |
| 77 | +PATH=$PATH:/home/dev/Desktop/workspace/Android/Sdk/tools |
| 78 | +PATH=$PATH:/home/dev/Desktop/workspace/Android/Sdk/platform-tools |
| 79 | +``` |
| 80 | +Note : replace "dev" inside the above command with your username |
| 81 | + |
| 82 | +3. android studio environment variables |
| 83 | +``` |
| 84 | +PATH=$PATH:/home/dev/Desktop/workspace/android-studio/bin |
| 85 | +``` |
| 86 | +Note : replace "dev" inside the above command with your username |
| 87 | + |
| 88 | +* Verify your updated PATH variable |
| 89 | +``` |
| 90 | +echo $PATH |
| 91 | +``` |
| 92 | + |
| 93 | +## step 5 : Install Android Studio Plugin |
| 94 | +Open android studio using terminal command studio.sh |
| 95 | +``` |
| 96 | +$ studio.sh |
| 97 | +``` |
| 98 | +* Select Configure => Plugins |
| 99 | +* Search for Flutter Plugin in the search bar and install |
| 100 | +* This will install both flutter and dart plugins |
| 101 | +* Restart Android Studio |
| 102 | +* New option to create a flutter application is now available in Android Studio |
| 103 | +* Click on "Create flutter application" option |
| 104 | +* Enter your app name, sdk location, project location, package name and some other required information |
| 105 | +* Click finish |
| 106 | +* Android studio will now create a starter flutter project |
| 107 | +* Happy Coding... |
| 108 | + |
| 109 | +### Accept android-licenses - Mandatory |
| 110 | +``` |
| 111 | +flutter doctor --android-licenses |
| 112 | +``` |
| 113 | + |
| 114 | +### Disable Flutter Analytics - Optional |
| 115 | +``` |
| 116 | +flutter config --no-analytics |
| 117 | +``` |
| 118 | + |
| 119 | +## step 6 : Run flutter doctor to test the environment setup |
| 120 | +Note : Keep your linux system up-to-date (System Updates) which helps in installing common dependencies required by flutter |
| 121 | +``` |
| 122 | +$ flutter doctor |
| 123 | +
|
| 124 | + Doctor summary (to see all details, run flutter doctor -v): |
| 125 | + [✓] Flutter (Channel stable, v1.9.1+hotfix.4, on Linux, locale en_US.UTF-8) |
| 126 | + |
| 127 | + [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2) |
| 128 | + [✓] Android Studio (version 3.5) |
| 129 | + [!] Connected device |
| 130 | + ! No devices available |
| 131 | +``` |
| 132 | +The above command should show all check marks to ensure that flutter installation is complete |
| 133 | + |
| 134 | +## step 7 : Common Errors/Warnings Guide while running flutter doctor command |
| 135 | + |
| 136 | +* Error : Unable to find git in your PATH |
| 137 | +Run command to Install git 2.x |
| 138 | +``` |
| 139 | +sudo apt-get install git |
| 140 | +``` |
| 141 | + |
| 142 | +* Install dependency only if required by flutter doctor summary |
| 143 | +``` |
| 144 | +sudo apt-get install lib32stdc++6 |
| 145 | +``` |
| 146 | + |
| 147 | +## step 8 : Install Visual Studio Code (Optional) |
| 148 | + |
| 149 | +Get Visual Studio Code Editor - Optional - [Download Visual Studio Code](https://code.visualstudio.com/) |
| 150 | +* Get the \. deb file for Ubuntu. Double Click on it and install via Ubuntu Software Center |
| 151 | +* Install VS Code Extensions |
| 152 | + * Flutter |
| 153 | + * Dart => this will automatically be installed with flutter extension |
| 154 | +* Go to View Menu => Select Command Palette or Press Ctrl+Shift+P |
| 155 | +* Type flutter in the Command Palette window |
| 156 | +* Select Flutter:New Project option |
| 157 | +* Provide a name to your project |
| 158 | +* Select your desired location to store all your projects |
| 159 | +* Flutter project will be created |
| 160 | +* Start coding... |
| 161 | + |
| 162 | +Note : We can use Android Studio or Visual Studio Code Editor [ANY ONE] to develop flutter apps |
| 163 | + |
| 164 | +## step 9 : Launch your Android Emulator |
| 165 | + |
| 166 | +Launch using Android Studio AVD Manager |
| 167 | +* Open Android Studio |
| 168 | +* Navigate to AVD Manager |
| 169 | +* Select a device from the list or Create a new device |
| 170 | +* Enable Hardware-GLES 2.0 |
| 171 | +* Select x86 image Android API Level with Google API - latest stable version of Android OS |
| 172 | +* Click Next & Finish the Emulator Config Setup |
| 173 | +* Click on PLAY BUTTON to start the emulator |
| 174 | + |
| 175 | +Launch using VS Code (Optional) |
| 176 | +* Check bottom-right corner of vs code |
| 177 | +* Click on "No Device" option |
| 178 | +* Select a emulator from the list |
| 179 | +* Click on the device name to start the emulator |
| 180 | + |
| 181 | +### Troubleshooting Android Emulator - Android Emulator not working ? |
| 182 | +Error List |
| 183 | +* Your CPU does not support required features (VT-x or SVM) |
| 184 | +* Please ensure KVM is properly installed |
| 185 | +* Error 1 : KVM is required to run this AVD |
| 186 | +* Error 2 : User does not have permission to use KVM (/dev/kvm) |
| 187 | + |
| 188 | +Error 1 : KVM is required to run this AVD |
| 189 | +* run command : |
| 190 | +``` |
| 191 | +sudo apt-get install qemu-kvm |
| 192 | + or |
| 193 | +sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils ia32-libs-multiarch |
| 194 | +``` |
| 195 | +* Restart your machine |
| 196 | + |
| 197 | +Error 2 : User does not have permission to use KVM (/dev/kvm) |
| 198 | +* run command : |
| 199 | +``` |
| 200 | +sudo adduser $USER kvm |
| 201 | +``` |
| 202 | +above command adds the current user |
| 203 | +``` |
| 204 | +echo $USER |
| 205 | +``` |
| 206 | +above command prints current username |
| 207 | + |
| 208 | +* Restart your machine |
| 209 | + |
| 210 | +### Useful Resources |
| 211 | + |
| 212 | +* [Android Developer Reference Docs - Emulator Acceleration](https://developer.android.com/studio/run/emulator-acceleration) |
| 213 | +* [Flutter Official Docs](https://flutter.dev/docs) |
| 214 | + |
0 commit comments