Use Bluestacks 4 to run Android apps with Flutter on Mac in 2 minutes
Why I wanted to switch to Bluestacks 4
I started off using Android Emulators from the Android Virtual Device (AVD) Manager. However, with the extra memory and CPU consumption from the emulator, my development speed really took a hit. Especially when I try to utilize the hot reload feature from Flutter, it takes several seconds to load the changes and heat up my computer at the same time.
Hence, I was looking for a slimmer and faster emulator alternative. After some research, I narrowed down to BlueStacks. Now the hot reload is almost instant and my computer stays cool while doing it.
But compared to using Android Emulators from AVD. There are some extra configurations to help Flutter detect Bluestacks as a runnable device. These configurations should be similar if you choose other Android Emulators. In this blog, we will use Bluestacks as an example.
Tools
- Flutter 1.20.2
- BlueStacks 4
Steps
There are two basic steps and one optional step. You can skip the last step if your emulator works fine after the first two steps.
1. Install BlueStacks
Install BlueStacks from here. For Mac users, if you run into security setting issues. You can refer to this blog.
After the BlueStacks Emulator is up and running, we can run flutter devices
. At this moment, Flutter cannot find the BlueStacks Emulator. That’s because we haven’t turned on the debug mode.
2. Enable Android Debug Bridge (ADB)
Go to BlueStacks >> Preferences >> Preferences
Check the Enable Android Debug Bridge (ADB)
option
Try to run flutter devices
again. At this point, you should see BlueStacks Emulator listed under flutter devices.
If the BlueStacks Emulator is not present, proceed to the next step.
3. (Optional) Connect with ADB
The BlueStacks Emulator is running on port 5555. Connect manually with adb adb connect localhost:5555
adb, aka Android Debug Bridge, is a command-line tool included in the Android SDK platform-tools packages. Refer to this guide on how to get it.
Lastly, run flutter devices
again to confirm the BlueStacks Emulator is detected.
Now flutter run
will install the apk on the BlueStacks Emulator.
Voilà.
Have fun coding :) Maybe with a cup of coffee~ ☕☕☕
Reference: