Flutter Emulator Setup
Again back to Flutter for mobile development, I realise the emulator I setup in previous article has default size 320x480
, which is too small and easy to lost motivation on mobile development. I need a better way to have larger resolution for development emulator!
To begin with, please make sure you have export below sourced already (of course, please include ndk and sdk installed)
export ANDROID_NDK_HOME=/usr/local/share/android-ndk
export ANDROID_SDK_ROOT=/usr/local/share/android-sdk
export PATH=$ANDROID_SDK_ROOT/emulator:$ANDROID_SDK_ROOT/tools:$PATH
2
3
I've also created a list of command in Makefile
for easy setup a running emulator for flutter:
# variable name can be found from make sdk-list
.PHONY: sdk-list
sdk-list:
sdkmanager --list
.PHONY: sdk-delete
sdk-delete:
sdkmanager --uninstall '$(name)'
.PHONY: sdk-install
sdk-install:
sdkmanager '$(name)'
.PHONY: emulator-list
emulator-list:
flutter emulator
.PHONY: enumlator-create
enumlator-create:
avdmanager create avd -n latest-android -k "$(name)"
.PHONY: emulator-run
emulator-run:
flutter emulator --launch latest-android
.PHONY: run
run:
flutter run
.PHONY: build
build:
flutter build
.PHONY: clean
clean:
flutter clean
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
skipping all details about how to setup flutter emulator as it's all mentioned in previous article
$ make emulator-run
$ make run
2
this will help power on your emulator and kick off your flutter app in it
# How to resize the emulator
# A command way
alternative than using make emulator-run
, the command below will help you serve a emulator with size 480x800
(by the way, this is most recommended size for mobile development)
.PHONY: emulator-size
emulator-size:
emulator -avd latest-android -skin 480x800
2
3
the downside will probably be, you have hold a terminal window to serve the emulator (maybe there's a command to specify the detach)
# A better way
Go to path ~/.android/avd/<emulator_name>.avd
and modify config.ini
file under it
$ vim ~/.android/avd/latest-android.avd/config.ini
insert skin.name=480x800
to that file, you probably getting something like:
PlayStore.enabled=false
abi.type=x86
avd.ini.encoding=UTF-8
hw.cpu.arch=x86
image.sysdir.1=system-images/android-29/google_apis/x86/
tag.display=Google APIs
tag.id=google_apis
skin.name=480x800
2
3
4
5
6
7
8
after all, you can start the emulator with make emulator-run
🎉 Enjoy working on a proper emulator!