Why?
You may wonder why I would like to run Android development environment without using it’s main tool, which in this case Android Studio, But regardless the heaven this tool will put me in, I’m searching for my own convenience.
To me Android Studio just an absolute nightmare, as soon as I run it my PC start screaming pigging me to close it, So I started a journey to find a way to install a full Flutter SDK without using Android Studio, and replace it with the tools I’d like to use, and here the lesson that came into existence.
Initializing
To be sure we are working on the same ground, we need to agree on some variables here:
- all commands in this tutorial are executed using windows
command prompt
, which you can run using one of the following methods:- Press
command prompt
hitEnter
. - Press
+ R
typecmd
hitEnter
.
- Press
- we will consider the dir
C:\Android
as main working directory just to keep everything in single place:
cd C:\
mkdir Android
cd Android
- it is necessary to follow the tutorial in the same order, otherwise some command may not work properly.
- this tutorial is performed on windows 10, and I’m not sure if it is going to work with older versions of windows.
Installing OpenJDK 8
We need to install Java OpenJDK 8 for this to work, download the zip file, extract it and rename the folder jdk8u202-b08
to openjdk
and copy it under C:\Android
folder, so its path will be:
C:\Android\openjdk
if you interested in other releases you can find it on github account AdoptOpenJdk
Installing Flutter SDK
Just like before download Windows version of flutter sdk, extract it, and copy the folder with the name flutter
to C:\Android
folder, so the full path will be:
C:\Android\flutter
Installing Android command tools
Download Windows version of Android command tools, and do the same thing, extract it and rename the tools
folder to sdk
, then copy it under C:\Android
folder, so the full path will be:
C:\Android\sdk
Set Some Environment variables
Because flutter development are based on several tools, we need to define some environment variables which let those tools contact each other, form command prompt run the following commands one by one:
setx JAVA_HOME "C:\Android\openjdk"
setx ANDROID_HOME "C:\Android"
setx ANDROID_SDK_ROOT "C:\Android\sdk"
setx path "%path%;"C:\Android\sdk;C:\Android\sdk\bin;C:\Android\flutter\bin"
⚠️***
Important
***: regard the last command, if your%path%
variable is longer than 1024 character it wont work, you need to set the%path%
variable manually fromControl Panel > System and Security > System > Advanced system settings
then chooseEnvironment Variables
, edit Path variable and addC:\Android\sdk;
,C:\Android\sdk\bin
andC:\Android\flutter\bin
respectively.
After executing above commands you need to close the Command Prompt
and run it again, so the commands in the next steps could work.
Download Android SDK
Considering that Flutter are based on Android SDK to work, so we need to download1 some packages, including (system images, platform tools, build tools, platforms, emulators, and intelhaxm), by using sdkmanager
command that is provided with Android command tools:
sdkmanager “system-images;android-27;default;x86_64”
sdkmanager “platform-tools”
sdkmanager “build-tools;28.0.3”
sdkmanager “platforms;android-28”
sdkmanager emulator
sdkmanager extras;intel;Hardware_Accelerated_Execution_Manager
To install intel haxm
for hardware acceleration, run following command:
C:\Android\extras\intel\Hardware_Accelerated_Execution_Manager>intelhaxm-android.exe
for this particular install, flutter was asking for build-tools;28.03
, and platforms;android-28
versions as minimum Android API level, if the flutter doctor -v
command ask for other versions, just replace the numbers in the above commands.
⚠️ Make sure to accept any license that appear by pressing
y
thenEnter
, or nothing will be downloaded.
Accept the licenses
Android sdk images have licenses that need to be accepted, you do that with the command:
sdkmanager --licenses
just press y
then Enter
for every license that appear.
Configure Flutter
Configure flutter to know the path of Android sdk dir.
flutter config --android-sdk C:\Android\
Create the Emulator
Create a new emulator with the name “nexus” or choose the name you want:
avdmanager -s create avd -n nexus -k “system-images;android-27;default;x86_64”
answer with [no] to the showed question.
Run the emulator
flutter emulators --launch nexus
⚠️ if the previous command doesn’t work as expected, it is mostly because of virtualization is not working or not supported in your CPU, to enable it refer to the extra section bellow to solve this issue, also you can find the error message with the emulator command, or if you have AMD processor, you will find the solution here.
Moment of truth
flutter doctor -v
This command should give all green and ok, ignore the Android Studio
complain, since this lesson is all about ignoring it in the first place, also if you don’t care about VS Code
ignore that too.
Test flutter code
inside flutter sdk folder, there is some examples of flutter apps, you could try any one of them, here we will go with hello world
as usual:
cd C:\Android\flutter\examples\hello_world
flutter run
Troubleshooting
Check virtualization support
Android emulator need CPU virtualization to get advantage of hardware acceleration, to see if your CPU support it, right click on the task bar
then choose task manager
, under performance
tab you should see Virtualization
on the bottom right and its status (enabled or disabled), if disabled just enable it from bios, if no Virtualization section at all, I’m sorry to tell that your CPU doesn’t support it, in this case go with the very slow option and run android image without hardware acceleration using the following command:
cd C:\Android\emulator
emulator -avd nexus -memory 768 -no-accel -gpu on
Virtualization for AMD CPU
if you have AMD processor, use WHPX
Other Good Emulator commands
emulator command
Run emulator using emulator command, it should be executed from inside C:\Android\emulator
cd C:\Android\emulator
emulator -avd nexus
This command is good to see error messages.
Create an emulator based on real device features
avdmanager -s create avd -n google-nexus -k “system-images;android-27;default;x86_64” -d 29
flutter emulators --launch google-nexus
you could change the 29 with any other device id, you can see all available devices with the command:
avdmanager list device
Delete existed virtual emulator
avdmanager delete avd -n nexus
List already created virtual emulators
avdmanager list avd
more help
avdmanager help
-
by the time I wrote this tutorial the latest version of the above images was 29, but I downloaded older version, so I can develop apps for wider range of Android OS versions, you can run the command
sdkmanager --list
to see available images and choose whatever you want. ↩︎
اقرأها بالعربية
تثبيت الفلاتر بدون استخدام أندرويد ستوديو