Last active
December 14, 2015 07:49
-
-
Save pboos/5053201 to your computer and use it in GitHub Desktop.
Android: Install/uninstall scala on rooted phone. Beware! Only use this if you know what you are doing!
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
<uses-library android:name="ch.pboos.scala-library-2.10.0"/> | |
<uses-library android:name="ch.pboos.scala-actors-2.10.0"/> | |
<uses-library android:name="ch.pboos.scala-collection-2.10.0"/> | |
<uses-library android:name="ch.pboos.scala-immutable-2.10.0"/> | |
<uses-library android:name="ch.pboos.scala-mutable-2.10.0"/> |
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 | |
# Created with information and examples from: | |
# https://github.com/jberkel/android-sdk-scala/blob/android-plugin/bin/createdexlibs | |
if [ "$ANDROID_HOME" = "" ]; then | |
echo "\$ANDROID_HOME is not set. Please set it!" | |
exit 1 | |
fi | |
if [ "$1" = "" ] || [ "$2" = "" ]; then | |
echo "Usage: ./scala-installer.sh install 2.10.0" | |
echo " ./scala-installer.sh uninstall 2.10.0" | |
exit 1 | |
fi | |
function android_make_system_writeable(){ | |
adb root | |
echo "Make /system on device writable..." | |
adb shell mount -o remount,rw /system | |
} | |
function android_make_system_read_only(){ | |
echo "Make /system on device read only again..." | |
adb shell mount -o remount,ro /system | |
} | |
function unpack_actors_if_needed() { | |
if [ $HAS_ACTOR_JAR -eq 0 ]; then | |
echo "Unpacking scala-actors.jar..." | |
${JAR:=jar} xf $WORKING_DIR/scala-actors.jar | |
fi | |
} | |
if [ "$1" = "install" ]; then | |
VERSION=$2 | |
LINK_DOWNLOAD="http://search.maven.org/remotecontent?filepath=org/scala-lang/scala-library/$VERSION/scala-library-$VERSION.jar" | |
LINK_ACTORS_DOWNLOAD="http://search.maven.org/remotecontent?filepath=org/scala-lang/scala-actors/$VERSION/scala-actors-$VERSION.jar" | |
WORKING_DIR=`pwd`/scala-installer | |
TMP_DIR=$WORKING_DIR/.`basename "$0"`_tmp | |
JVM_LIBS_DIR=$TMP_DIR/jvm-libs | |
DEX_LIBS_DIR=$WORKING_DIR/framework | |
mkdir -p $JVM_LIBS_DIR/scala-library/scala \ | |
$JVM_LIBS_DIR/scala-collection/scala \ | |
$JVM_LIBS_DIR/scala-immutable/scala/collection \ | |
$JVM_LIBS_DIR/scala-mutable/scala/collection \ | |
$JVM_LIBS_DIR/scala-actors/scala \ | |
$DEX_LIBS_DIR | |
########## | |
# Download | |
########## | |
cd $WORKING_DIR | |
echo "Downloading scala-library.jar..." | |
curl -o scala-library.jar $LINK_DOWNLOAD | |
echo "Downloading scala-actors.jar..." | |
curl -o scala-actors.jar $LINK_ACTORS_DOWNLOAD | |
HAS_ACTOR_JAR=$? | |
########## | |
# Split up | |
########## | |
DX=$ANDROID_HOME/platform-tools/dx | |
( \ | |
cd $JVM_LIBS_DIR/scala-library/ && \ | |
echo "Unpacking scala-library.jar..." && \ | |
${JAR:=jar} xf $WORKING_DIR/scala-library.jar && \ | |
echo "Generating scala-collection.jar..." && \ | |
cp library.properties $JVM_LIBS_DIR/scala-collection/ && \ | |
cp -r META-INF $JVM_LIBS_DIR/scala-collection/ && \ | |
cp -r scala/collection $JVM_LIBS_DIR/scala-collection/scala/ && \ | |
echo "Generating scala-immutable.jar..." && \ | |
cp library.properties $JVM_LIBS_DIR/scala-immutable/ && \ | |
cp -r META-INF $JVM_LIBS_DIR/scala-immutable/ && \ | |
cp -r scala/collection/immutable $JVM_LIBS_DIR/scala-immutable/scala/collection/ && \ | |
echo "Generating scala-mutable.jar..." && \ | |
cp library.properties $JVM_LIBS_DIR/scala-mutable/ && \ | |
cp -r META-INF $JVM_LIBS_DIR/scala-mutable/ && \ | |
cp -r scala/collection/mutable $JVM_LIBS_DIR/scala-mutable/scala/collection/ && \ | |
unpack_actors_if_needed && \ | |
echo "Generating scala-actors.jar..." && \ | |
cp library.properties $JVM_LIBS_DIR/scala-actors/ && \ | |
cp -r scala/actors $JVM_LIBS_DIR/scala-actors/scala/ && \ | |
rm -rf $JVM_LIBS_DIR/scala-collection/scala/collection/immutable && \ | |
rm -rf $JVM_LIBS_DIR/scala-collection/scala/collection/mutable && \ | |
rm -rf scala/collection scala/actors \ | |
) | |
for dir in "scala-library" "scala-collection" "scala-immutable" "scala-mutable" "scala-actors" ; do | |
echo "Converting $dir.jar into a dex file..." | |
${JAR:=jar} cf $JVM_LIBS_DIR/${dir}.jar -C $JVM_LIBS_DIR/$dir . | |
$DX --dex --output=$DEX_LIBS_DIR/$dir.jar $JVM_LIBS_DIR/$dir.jar | |
done | |
cp $JVM_LIBS_DIR/scala-library/library.properties $DEX_LIBS_DIR/ | |
rm -rf $TMP_DIR > /dev/null | |
########################### | |
# Install on android device | |
########################### | |
android_make_system_writeable | |
for dir in "scala-library" "scala-collection" "scala-immutable" "scala-mutable" "scala-actors" ; do | |
echo "Uploading $dir.jar to device..." | |
adb push "$DEX_LIBS_DIR/$dir.jar" "/system/framework/ch.pboos.$dir-$VERSION.jar" | |
TEMP_FILE=permission_tmp.xml | |
PERMISSION_FILE=/system/etc/permissions/ch.pboos.$dir-$VERSION.xml | |
echo "Creating $PERMISSION_FILE file on device..." | |
echo "<permissions>" > $TEMP_FILE | |
echo "<library name=\"ch.pboos.$dir-$VERSION\" file=\"/system/framework/ch.pboos.$dir-$VERSION.jar\" />" >> $TEMP_FILE | |
echo "</permissions>" >> $TEMP_FILE | |
adb push "$TEMP_FILE" "$PERMISSION_FILE" | |
done | |
android_make_system_read_only | |
echo "Reboot your phone/tablet" | |
fi | |
if [ "$1" = "uninstall" ]; then | |
echo "Uninstalling..." | |
android_make_system_writeable | |
echo "Removing files of version $VERSION" | |
adb shell "rm /system/framework/ch.pboos.scala*$VERSION.jar" | |
adb shell "rm /system/etc/permissions/ch.pboos.scala*$VERSION.xml" | |
android_make_system_read_only | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In my system I have to change this:
DX=$ANDROID_HOME/platform-tools/dx
to this:
DX=$ANDROID_HOME/build-tools/18.1.0/dx
It corresponds to line 71.
Congratulations for your work!
In a Galaxy Mini it works only with Cyanogenmod, not with the official rooted ROM.