Last active
October 27, 2017 15:07
-
-
Save androidovshchik/f868843c4a728dc7c91095826e12a2bf to your computer and use it in GitHub Desktop.
Android Studio build script file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# CHANGE THESE | |
app_package="com.example" | |
dir_app_name="AppName" | |
MAIN_ACTIVITY="ActivityMain" | |
ADB="adb" # how you execute adb | |
ADB_SH="$ADB shell su -c" | |
path_sysapp="/system/priv-app" # assuming the app is priviledged | |
apk_host="./app/build/outputs/apk/app-debug.apk" | |
apk_name=$dir_app_name".apk" | |
apk_target_dir="$path_sysapp/$dir_app_name" | |
apk_target_sys="$apk_target_dir/$apk_name" | |
# Delete previous APK | |
rm -f $apk_host | |
# Compile the APK: you can adapt this for production build, flavors, etc. | |
./gradlew assembleDebug || exit -1 # exit on failure | |
# Install APK: using adb su | |
$ADB_SH "mount -o rw,remount /system" | |
$ADB_SH "chmod 777 /system/lib/" | |
$ADB_SH "mkdir -p /sdcard/tmp" 2> /dev/null | |
$ADB_SH "mkdir -p $apk_target_dir" 2> /dev/null | |
$ADB push $apk_host /sdcard/tmp/$apk_name 2> /dev/null | |
$ADB_SH "mv /sdcard/tmp/$apk_name $apk_target_sys" | |
$ADB_SH "rmdir /sdcard/tmp" 2> /dev/null | |
# Give permissions | |
$ADB_SH "chmod 755 $apk_target_dir" | |
$ADB_SH "chmod 644 $apk_target_sys" | |
# Stop the app | |
$ADB shell "am force-stop $app_package" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment