sources: developer.android.com, docs in sdk directory.
/home/<USER>/Android/Sdk/tools/emulator -force-32bit -avd <AVD NAME TO LAUNCH>
#path of emulator was discovered in android studio's console as error occurred while launch.
sudo apt-get install KVM
#Check KVM by:
kvm-ok
#If Error, install KVM by following:
sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
#SQLiteOpenHelper- onCreate() function called only when new database is created.
#add sdk/tools & sdk/platform-tools folder to system's path. this gives access to android command.
#Create a Project with Command Line Tools
1- create project. In Android studio, use "File" > "New Project" menu.
android list targets # This lists all available targets with id(parameter to create) and other details.
android create project --target <TARGET-ID> --name <APP_NAME> --path <DIRECTORY_FOR_PROJECT> --activity <ACTIVITY_NAME> --package <PACKAGE_FOR_ACTIVITY_JAVA_CLASS>
2- prepare device for execution. Connect target device(usb debugging enabled) using OEM provided data cable.
OR Configure emulator using following. In Android studio use "Tools" > "Android" > "AVD Manager".
android avd # This start android device manager to configure a device emulator. Files for emulator can be found in <USERS_HOME_DIR>/.android/avd
#1 On the AVD Manager main screen (figure 1), click Create Virtual Device.
#2 In the Select Hardware window, select a device configuration, such as Nexus 6, then click Next.
#3 Select the desired system version for the AVD and click Next.
#4 Verify the configuration settings, then click Finish.
#5 In the Android Virtual Device Manager window, click Create.
#6 Enter an AVD Name.
#7 Select a Device type.
#8 When you select a device type, most of the fields auto-populate.
#9 For Skin select HVGA.
#10 For SD Card, enter something small, like 10 MiB.
#11 It really doesn't matter what you enter here since you're not using any storage. But if you reuse this AVD, you might have to adjust this setting.
#12 Ignore the Emulation Options and click OK.
#13 In the Result screen, click OK.
#14 Close the Android Virtual Device Manager window.
3- build app.
./gradlew assembleDebug #This generates apk in app/build/outputs/apk/ path.
4- run app. On Android studio click "Run" > "Run 'app'"
adb install <APK_BUILT_IN_PREVIOUS_STEP>
Starting from scratch on ubuntu vm.... either get android studio and move to development peacefully... Or follow cmd-line approach...
download. cmd-tools
extract in /opt/
cd <extracted_dir>/cmdline-tools
cmdline-tools$ ./bin/sdkmanager --sdk_root=/opt/android/sdks/ --list | grep android-28 > android-28_related_packages.txt
gedit android-28_related_packages.txt & #first column in file is package name in format "<ResourceType>;<Version>"
sudo ./bin/sdkmanager --sdk_root=/opt/android/sdks/ --install "platforms;android-28" "system-images;android-28;default;x86_64" "emulator" "platform-tools" #you will be prompted for license agreement, go for 'y'...
./bin/sdkmanager --sdk_root=/opt/android/sdks/ --list_installed
sudo ./bin/avdmanager create avd --name PIXEL-2 -k "system-images;android-28;default;x86_64" ## resulted in error "package emulator not found", if you didnt installed package "emulator" on step #
sudo ./bin/avdmanager list avd
sudo ./bin/avdmanager delete avd -n PIXEL-2 # removed as it was created using sudo..