Shortcuts for development


#1

I’ve created a small windows-batch file which makes running ionic on you device a little easier. For the sake of sharing, here it is. Save as actions.bat (or whatever you like) in you app folder.

@ECHO OFF
CLS
ECHO 1. Fresh Android Build  and Install on device
ECHO 2. Fresh Android Build
ECHO 3. Android Build and Install on device
ECHO 4. Android Build 
ECHO 5. Run on device
ECHO.

CHOICE /C 12345 /M "Enter your choice:"

IF ERRORLEVEL 5 GOTO runDevice
IF ERRORLEVEL 4 GOTO build
IF ERRORLEVEL 3 GOTO buildInstall
IF ERRORLEVEL 2 GOTO cleanBuild
IF ERRORLEVEL 1 GOTO cleanBuildInstall

:cleanBuildInstall
ECHO removing, building and installing on device
adb uninstall [com.ionic.appname] && ionic platform rm android && ionic platform add android && ionic build android && adb install  [FOLDER_OF_APP]/platforms/android/build/outputs/apk/android-debug.apk && adb shell am start -n [com.ionic.appname]/.MainActivity
GOTO END

:cleanBuild
ECHO removing android and building
ionic platform rm android && ionic platform add android && ionic build android 
GOTO END

:buildInstall
ECHO Building, installing and running on device
adb uninstall [com.ionic.appname] && ionic build android && adb install  [FOLDER_OF_APP]/platforms/android/build/outputs/apk/android-debug.apk && adb shell am start -n [com.ionic.appname]/.MainActivity
GOTO END

:build
ECHO building android
ionic build android 
GOTO END

:runDevice
ECHO running on device with L S C parameters
ionic run android --device -l -s -c
GOTO END

Some options might a bit harsh (like cleanBuildInstall), but sometimes i like to start clean.