Skip to content

Instantly share code, notes, and snippets.

@samukasmk
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save samukasmk/948e249db46df77f897e to your computer and use it in GitHub Desktop.

Select an option

Save samukasmk/948e249db46df77f897e to your computer and use it in GitHub Desktop.
Script tool to dynamically deploy a kivy app without to create un apk package, using (Kivy Launcher) app
#!/bin/bash
#
# script: deploy_kivy_app_with_kivy_launcher.sh
#
# by: Samuel Maciel Sampaio [20140717]
#
# contact: samukasmk@gmail.com
#
# goal:
# Develop kivy apps for android and quickly test directly in your
# android devices with a simple and dynamically way, without to
# create un apk package (that takes a lot lot time!)
#
# How can i do this ? Transfering the files of your kivy project
# directly to sdcard of the android device and start the app (Kivy
# Launcher)
#
# Thanks, Have Fun!
#
# SET YOUR VARIABLES HERE
ANDROID_SDK_PATH='~/.buildozer/android/platform/android-sdk-21'
KIVY_PROJECT_PATH='/Path/to/your/kivy/project'
# down here let me define by myself
KIVY_REMOTE_FOLDER='/sdcard/kivy'
KIVY_PROJECT_FOLDER=$(basename $KIVY_PROJECT_PATH)
IGNORE_TERMS=( .apk .git buildozer )
echo -n "Defining the adb command path: "
if [ -f "$ANDROID_SDK_PATH/platform-tools/adb" ];
then
ADB="$ANDROID_SDK_PATH/platform-tools/adb";
echo -e "[ OK ]\nadb path: $ADB\n"
elif [ -f "$ANDROID_SDK_PATH/tools/adb" ];
then
ADB="$ANDROID_SDK_PATH/tools/adb";
echo -e "[ OK ]\nadb path: $ADB\n"
else
echo -e "[FAILED]\nImpossible to find 'adb' command in SDK Path: $ANDROID_SDK_PATH"
exit 1
fi
echo -n "Checking if there are devices connected: "
DEVICES_CONNECTED=$($ADB devices | grep -v List | grep -v '^$' | wc -l)
if [ "$DEVICES_CONNECTED" -lt "1" ];
then
echo -e "[FAILED]\nNot Found Devices Connected with this computer \!"
exit 2
else
echo -e "[ OK ]\n"
fi
cd $(dirname $KIVY_PROJECT_PATH)
IGNORED_FILES=''
for TERM in ${IGNORE_TERMS[*]};
do
IGNORED_FILES="$IGNORED_FILES | grep -v '$TERM'"
done
echo -n "Finding kivy project folders: "
KIVY_PROJECT_FOLDERS=($(eval find $KIVY_PROJECT_FOLDER -type d $IGNORED_FILES))
if [ "$?" -eq "0" ];
then
echo -e "[ OK ]\n"
else
echo -e "[FAILED]\n"
fi
echo -n "Finding kivy project files: "
KIVY_PROJECT_FILES=($(eval find $KIVY_PROJECT_FOLDER -type f $IGNORED_FILES))
if [ "$?" -eq "0" ];
then
echo -e "[ OK ]\n"
else
echo -e "[FAILED]\n"
fi
echo -n "Ensuring that Kivy folders exists..."
$ADB shell mkdir -p $KIVY_REMOTE_FOLDER
for KIVY_PROJECT_FOLDER in ${KIVY_PROJECT_FOLDERS[*]};
do
$ADB shell mkdir -p $KIVY_REMOTE_FOLDER/$KIVY_PROJECT_FOLDER
done
echo -e "\n"
echo "Initilizing file transfer:"
for KIVY_PROJECT_FILE in ${KIVY_PROJECT_FILES[*]};
do
echo "$KIVY_PROJECT_FILE -> $KIVY_REMOTE_FOLDER/$KIVY_PROJECT_FILE "
$ADB push -p $KIVY_PROJECT_FILE $KIVY_REMOTE_FOLDER/$KIVY_PROJECT_FILE
echo ""
done
$ADB shell am start -n org.kivy.pygame/org.renpy.android.ProjectChooser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment