NOTE: 1.2.0 is the last version published using
addSbtPlugin("com.hanhuy.sbt" % "android-protify" % "1.2.0")
,
all future updates can be accessed by using
addSbtPlugin("org.scala-android" % "sbt-android-protify" % VERSION)
- Multiple language support: Java (including retrolambda), Scala, Kotlin
- No code changes to app required!
- Support for appcompat-v7, design and support-v4 libraries
- Works with most existing android projects
- Android devices api level 5+
- Dex sharding for near-instant deployment
- Install sbt from http://scala-sbt.org, homebrew, ports, or your package manager of choice
- Optionally add
idea-sbt-plugin
to run SBT inside of Android Studio - Install the
sbt-android-gradle
SBT plugin to automatically load your gradle build. From the base of your Android project, do:mkdir project
echo 'addSbtPlugin("org.scala-android" % "sbt-android-gradle" % "1.3.2")' > project/plugins.sbt
echo >> project/plugins.sbt
- If you have any flavors or build types that must be loaded:
echo 'android.Plugin.withVariant("PROJECT-NAME (e.g. app)", Some("BUILD-TYPE"), Some("FLAVOR"))' > build.sbt
echo >> build.sbt
- Replace
Some(...)
withNone
if you don't have a flavor or build type to apply
- Replace
- Install the
sbt-android-protify
plugin, also from the project base, do:echo 'addSbtPlugin("org.scala-android" % "sbt-android-protify" % "1.4.4")' >> project/plugins.sbt
- For every application sub-project, do:
echo 'enablePlugins(AndroidProtify)' > APP-PROJECT-DIR/protify.sbt
- Launch SBT,
sbt
(first time's gonna take a while, downloading the internet and all) - Build and install the application normally, at least once:
PROJECT-NAME/android:install
(orrun
instead ofinstall
) -- the first time will take a while too, since it will download the parts of the internet that your app requires
- Thereafter:
PROJECT-NAME/protify
, do~PROJECT-NAME/protify
to automatically trigger on all source changes
- Install sbt from http://scala-sbt.org, homebrew, ports, or your package manager of choice
- Install sbt-android:
echo 'addSbtPlugin("org.scala-android" % "sbt-android" % "1.7.7")' > ~/.sbt/0.13/plugins/android.sbt
- Start from an existing or new project (for trivial projects):
sbt "gen-android ..."
to create a new project,sbt gen-android-sbt
to generate sbt files in an existing project. Non-trivial projects will need more advanced sbt configuration.- Alternatively, use
sbt-android-gradle
when working with an existing gradle project:echo 'addSbtPlugin("org.scala-android" % "sbt-android-gradle" % "1.3.2")' > project/plugins.sbt
- Alternatively, use
- Add the protify plugin:
echo 'addSbtPlugin("org.scala-android" % "sbt-android-protify" % "1.4.4")' >> project/plugins.sbt
- Add
AndroidProtify
:echo enablePlugins(AndroidProtify) >> build.sbt
- Run SBT
- Select device to run on by using the
devices
anddevice
commands. Run on all devices by executingset allDevices in Android := true
android:run
, and~protify
- Alternatively, high speed turnaround can be achieved with
protify:install
andprotify:run
to pretend the app is getting updated, rather than using the live-code mechanism.
- Alternatively, high speed turnaround can be achieved with
- Enjoy
To make it so that protify can be run when triggered in the IDE with a keystroke, do the following
- Install Scala plugin in IDE
- Install SBT plugin in IDE
- Create a new
Run
configuration, press the dropdown next to the play button, selectEdit Configurations
- Press
+
->Android Application
- Name the configuration
protify
,instant run
, or whatever you like - Select the
app
module - Select
Do not deploy anything
- Select
Do not launch activity
- For target device, select anything that will not prompt
- Uncheck
Activate tool window
- Remove
Make
fromBefore launch
Before launch
->+
->Add New Configuration
->SBT
- In the drop down, edit the text to say
protify
- In the drop down, edit the text to say
- Press
- You can now invoke
protify
directly as a run configuration and see changes instantly (FSVO instant) appear on-device.
- Just do any of the above getting started steps and follow your own workflow.
- Manifest changes will require
android:install
again (i.e. adding/removing: activities, services, permissions, receivers, etc). Incremental deployment cannot modify manifest. - No longer true with build-tools 24.0.0 and newer: Deleting a
constant value from
R
classes (removing resources) will require runningprotify:clean
or else the build will break - Object instance state, including singleton and static, will not be restored
upon deploying new dex code (or resources when on device api level <14).
All Android
Bundle
d state will be restored in all situations - Android instrumented tests are not supported. They will fail to run because of the sharded dex and re-located resource files.
- NDK is not supported at the moment (initial install works, no
protify
updates when jni code changes)
- Support NDK. This means delivering the
.so
libraries from the build environment to the device, placing them into the correct location and triggering an app restart - Support instrumented testing. This would need implementation similar to
MultiDexTestRunner