Just a project to try out Android Annotation Processor in the new Java8 and Jack&Jill enviornment. Also check if libraries and testing frameworks work with it.
First of all, make sure you know what is JACK&JILL. Check this talk about The Jack and Jill Build System on Youtube.
- Instant Run
- Data Binding (
android.dataBinding.enabled = true
will fail) - Minifying For Tests (Enable proguard for
release
and settestBuildType 'release'
will fail)
- Dagger 2.4
- Dagger 2.5 (
classpath 'com.google.guava:guava:19.0'
needed) - AutoValue 1.2
- Butterknife 8.1.0
- LoganSquare 1.3.6
- JUnit 4.12
- Robolectric 3.1
- Mockito 1.10.19
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-alpha4'
}
}
android {
compileSdkVersion 24
buildToolsVersion '24.0.0'
defaultConfig {
targetSdkVersion 24
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
// dagger 2
compile 'com.google.dagger:dagger:2.5'
annotationProcessor 'com.google.dagger:dagger-compiler:2.5'
// auto-value
compile 'com.google.auto.value:auto-value:1.2'
annotationProcessor 'com.google.auto.value:auto-value:1.2'
// butterknife
compile 'com.jakewharton:butterknife:8.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.1.0'
// logan square
compile 'com.bluelinelabs:logansquare:1.3.6'
annotationProcessor 'com.bluelinelabs:logansquare-compiler:1.3.6'
}
It is only supported if you set minSdkVersion
to 24
or above.
It is simply not supported now. Notification will be shown whenever you try to use it.
If you put the following, error will be thrown.
android {
dataBinding {
enabled = true // Error: Data Binding does not support Jack builds yet
}
}
If you put the following, error will be thrown.
Error:A problem occurred configuring project ':app'.
> Minifying the variant used for tests is not supported when using Jack.
android {
testBuildType 'release'
buildTypes {
release {
minifyEnabled true
signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Stream api is not working working after upgrading to 2.2.0-alpha3
, follow ticket. It means the following doesn't work:
Arrays.asList(3, 1, 2).stream()
.sorted()
.map(String::valueOf)
.forEach(integer -> view.setText(view.getText() + " => " + integer));
Classes are generated in
build/intermediates/classes/
instead of build/generated/source/
, so they are not treated as source by Android Studio. Code referencing them will be displayed red. This issue has a temporary solution
- Updated android plugin version to
com.android.tools.build:gradle:2.2.0-alpha4
. - Extra dependency
com.google.guava:guava:18.0
is no longer needed - Java 8 stream api is fixed.
- Classes are generated in
build/generated/source/apt
now. compileSdkVersion
is updated to24
buildToolsVersion
is updated to24.0.0
targetSdkVersion
is updated to24
- Updated android plugin version to
com.android.tools.build:gradle:2.2.0-alpha3
. - Java 8 stream api is no longer working.
- Ticket filed.
- Added script to temporarily place generated code into source directory.
- See here: gist
- Alternative with gradle plugin. See changes in a pull request
- Updated android plugin version to
com.android.tools.build:gradle:2.2.0-alpha2
. - Extra dependency
com.google.guava:guava:18.0
is still neccessary. Ticket filed. - Classes are generated in a bad location
build/intermediates/classes/
- Testing code using Java8 with Annotation Processor from
com.android.tools.build:gradle:2.2.0-alpha1
. - Android
N
must be targeted and latest build tool24.0.0 rc4
must be used to work. - It is working but generated code cannot be recognized by Android Studio.
- Extra library is needed to work ->
com.google.guava:guava:18.0
. - Classes are generated in
build/intermediates/classes/
instead ofbuild/generated/source/