Skip to content

Instantly share code, notes, and snippets.

@d0rsha
Last active March 28, 2019 14:44
Show Gist options
  • Save d0rsha/e347bb756830b11d425f8b8b24dabf8f to your computer and use it in GitHub Desktop.
Save d0rsha/e347bb756830b11d425f8b8b24dabf8f to your computer and use it in GitHub Desktop.
[Environment] Ionic setup android env #ionic #android

Prerequisite

Run sudo find / -type d -name 'android' and find
*/Android/Sdk/*. We will export it to our PATH in our current shell. Follow https://stackoverflow.com/questions/23042638/how-do-i-set-android-sdk-home-environment-variable

export ANDROID_HOME=$HOME/<THAT_PATH_YOU_KNOW>/Android/sdk
# Nope? 
# avdmanager, sdkmanager
# export PATH=$PATH:$ANDROID_HOME/tools/bin
# adb, logcat
# export PATH=$PATH:$ANDROID_HOME/platform-tools
# emulator
# export PATH=$PATH:$ANDROID_HOME/emulator
# apksigner, zipalign
# export PATH=$PATH:$ANDROID_HOME/build-tools

Before you continue make sure everything is set up correctly by testing:

echo $JAVA_HOME
echo $ANDROID_HOME
gradle -v
android
adb

! For windows check OEM for you specific device

To run on local android device

adb tcpip 5555                  
adb connect device_ip_address   
npm install                     ## Don't forget to install dependencies!!
ionic cordova run android       ## Add '-l' for live reload (It's veeery niice)

If it's not working checkout
https://ionicframework.com/docs/installation/android
https://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html

Debug with Chrome

Further to debug with chrome tools open chrome://inspect/#devices
Make sure your device is connected, read more at https://ionic.zone/debug/remote-debug-your-app#android
Make sure your device is running the same chrome version as your environment https://www.google.com/linuxrepositories/
Find Ionic App <device_ip>:<port> inspect and hit inspect

To emulate ionic cordova emulate [<platform>] [options] (https://ionicframework.com/docs/cli/commands/cordova-emulate) Check virtuals devices w/ android list avd

SOLUTION FOR some errors downgrade cordova version

npm install -g cordova@8.1.2
npm install cordova-android@7.1.4
ionic cordova platform remove android
ionic cordova platform add android
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment