Skip to content

Instantly share code, notes, and snippets.

@unitycoder
Forked from DanielJenkyn/install_obb.sh
Created February 12, 2024 09:00
Show Gist options
  • Save unitycoder/49db184ca8133cb9fb5fc1cf7da9c837 to your computer and use it in GitHub Desktop.
Save unitycoder/49db184ca8133cb9fb5fc1cf7da9c837 to your computer and use it in GitHub Desktop.
Script to install .apk and .obb (Split binary) onto Android device

This bash script was written to easily install an .apk and the matching .obb file (also know as a split binary build) on an Android device. It's basically just a wrapper for some adb commands.

Prerequisites

  • This script assumes you have adb (Android debug bridge) installed
  • This script has only been tested on macOS

How to run

  • Download this script
  • Change the project_name in the script or specify a project name with -f (See options below)
  • Place script where the .apk and .obb are located
  • cd to .apk and .obb location,type install_obb.sh
  • Huzzah!
  • Side-note - If you have multiple .apk and .obb files in the directory with the same name, the script will just take the most recent

Options

  • install_obb.sh -r - re-install the app and keep its data on the device. Off by defaut
  • install_obb.sh -f - Overwrite default project name in script

To run script globally

  • Put script in /usr/local/bin, or directory of your choice
  • Then export path to bash profile
  • echo ‘export INSTALL_OBB_SCRIPT=/usr/local/bin/install_obb.sh’ >> ~/.bash_profile
  • echo ‘export PATH=${PATH}:$INSTALL_OBB_SCRIPT >> ~/.bash_profile
  • . ~/.bash_profile
  • Now you can script from anywhere
  • Double Huzzah!

Author

  • Daniel Jenkyn
#!/bin/bash
project_name= com.jenkyncorp.bestapp
reinstall=
# Takes the most recent .apk and .obb (If you have multiple files)
OBB=$(ls -t *.obb | head -n1)
APK=$(ls -t *.apk | head -n1)
while [ "$1" != "" ]; do
case $1 in
-f | --file ) shift
project_name=$1
;;
-r | --reinstall ) reinstall=1
;;
* ) usage
exit 1
esac
shift
done
echo "Creating obb directory and pushing obb ..."
adb shell mkdir -p /sdcard/Android/obb/$project_name
adb push -p $OBB /sdcard/Android/obb/$project_name/
if [ “$reinstall” = “1” ]; then
adb install -r $APK
else
adb install $APK
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment