Android Studio
Setup for Linux Debian
- Install Java — follow this guide:
2. Install Android Studio
Download the Android Studio .tar.gz:
https://developer.android.com/studio
Decompress it:
tar -xzvf android-studio-*.tar.gz
Move it to /opt :
sudo mv android-studio /opt
3. Install dependencies:
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386
4. Run installer:
cd /opt/android-studio/bin
./studio.sh
Click NEXT to all steps.
- It will install the Android SDK, Android Emulator, and everything needed to create an android application (Google system image, build tools, platform tools, virtual device — it takes a while to completes, so wait).
https://developer.android.com/static/studio/videos/studio-install-linux.mp4
The SDK will be installed into the default location at your home: ~/Android/Sdk
5. Configure the environment variables for it:
sudo echo "export ANDROID_HOME=~/Android/Sdk" >> ~/.bashrc
sudo echo "export PATH=$PATH:$ANDROID_HOME/tools" >> ~/.bashrc
sudo echo "export PATH=$PATH:$ANDROID_HOME/tools/bin" >> ~/.bashrc
sudo echo "export PATH=$PATH:$ANDROID_HOME/platform-tools" >> ~/.bashrc
source ~/.bashrc
echo $PATH
As optional, you could add a alias to run android
sudo echo "alias android='/opt/android-studio/bin/studio.sh'" >> ~/.bashrc
source ~/.bashrc
echo $PATH
and also add the emulator to the path:
sudo echo "export PATH=$PATH:$ANDROID_HOME/emulator" >> ~/.bashrc
source ~/.bashrc
echo $PATH
Or just directly edit the .bashrc adding to the path the following code line (not replacing):
export JAVA_HOME=/usr/lib/jvm/java-in-use
export ANDROID_HOME=~/Android/Sdk
export PATH=$JAVA_HOME/bin:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator
Note: Due to a current emulator issue, emulator can`t launch avds, to workaround it until it`s not fixed, create a alias to the emulator at ~/.bashrc
alias emu="$ANDROID_HOME/tools/emulator"
So, use ‘emu’ to launch emulator instead of ‘emulator’!
emulator -list-avds
emu -list-avds
emulator @<android_avd_name>
emu @<android_avd_name>
emulator -avd <android_avd_name>
emu -avd <android_avd_name>
6. Reopen the Android Studio
android
or
cd /opt/android-studio/bin
./studio.sh
7. Enjoy it!
Now you are ready to create a new android application or use android emulator.
If you are using a real Android device, turn on the Debug mode, plugin the mobile phone, and run the following code to list devices (and emulators) connected:
adb devices
Some adb commands:
- adb install package.apk — Installs the package.
- adb uninstall package.name — Uninstalls the package (com.rovio.angrybirds).
- adb push /home/file /sdcard/file — Pushes a file to /sdcard/file
- adb pull /sdcard/file /home/file — Pulls a file from /sdcard/file
- adb logcat — device’s log, useful for debugging.
- adb shell — interactive Linux command-line shell on your device.
- adb shell command — runs specific command
To use the Android Emulator, open AVD Manager to create a new one, or just run the already available emulator:
emulator -list-avds
OR
emu -list-avds
Pixel_3a_API_34_extension_level_7_x86_64
emulator -avd Pixel_3a_API_34_extension_level_7_x86_64
OR
emu -avd Pixel_3a_API_34_extension_level_7_x86_64
or
./Android/Sdk/emulator/emulator -list-avds
Pixel_3a_API_34_extension_level_7_x86_64
./Android/Sdk/emulator/emulator -avd Pixel_3a_API_34_extension_level_7_x86_64
Note: To enable keyboard input, access the emulator settings, click in advanced settings, and enable the item " Enable keyboard input"
To create a new Android Project, open it and select New Project, after that select the type: Phone/Tablet, Wear OS, Android TV, Automotive, and also the kind of the activity/layout — And finally setup the Project details.
You can use different languages to develop for Android, the old Java or the newer Kotlin, the list is big:
- Java, older and first official one
- Kotlin, newer official one since 2017
- C++ using NDK
- C# with .NET (for windows)
- Python with Kivy
- HTML, CSS and JavaScript with Adobe PhoneGap
- Dart with Flutter
- Lua with Corona
- …
For Test Automation, use some tools like Appium and Nightwatch.js — it will be available in a future post here asap, just wait for it!
For now, check it out the Android Studio doc for more information: https://developer.android.com/docs