the shoulders of a Giant (Java) • Runs a JVM • Android developers shouldn't be suffering • Java on Android is very verbose • And the main development language on the platform 7
is a dynamic language • Not everything done at compile time • Intensive use of reflection • Potentially slow invocation pathes • Battery? • Bytecode is different • Classes at runtime? 8
Android in the standard distribution • Building a full Android application in Groovy • Main focus on @CompileStatic • Optional use of dynamic Groovy 18
a specific Android jar • Use of the grooid classifier • Replaces java.beans use with openbeans • Workarounds for Android specific behavior • Reduced number of methods in bytecode • Important for the 64k limit of dex files 23
default build system for Android • apply plugin: 'com.android.application' • Uses a non standard compilation process • Without Groovy specific plugin, lots of trickery involved • Thus apply plugin: apply plugin: 'me.champeau.gradle.groovy-android' • Supports both the application and library plugins 24
@OnClick(R.id.button) void onButtonClicked(Button button) { Toast.makeText(this, "Button clicked", Toast.LENGTH_SHOT).show() } @OnBackground void doSomeProcessing(URL url) { // Contents will be executed on background ... } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) // This must be called for injection of views and callbacks to take place SwissKnife.inject(this) } }
Groovy on low end-devices • Use @CompileStatic whenever possible • The infamous 64k method count • Use ProGuard! • Tooling support • Groovy not fully supported by Android Studio • Google support • Android Gradle plugin updates are very frequent
to update Android Studio right before the talk, so I have the latest possible version in the socalled Canary channel. What could possibly go wrong?” Ken Kousen, September 10th, 2014