Configuring Your Android Build

To get started you must add the Micronaut annotation processors to the processor classpath using the annotationProcessor dependency configuration.

The Micronaut micronaut-inject-java dependency should be included in both the annotationProcessor and compileOnly scopes of your Android build configuration:

Example Android build.gradle

  1. dependencies {
  2. ...
  3. annotationProcessor "io.micronaut:micronaut-inject-java:2.2.3"
  4. compileOnly "io.micronaut:micronaut-inject-java:2.2.3"
  5. ...
  6. }

If you use lint as part of your build you may also need to disable the invalid packages check since Android includes a hard coded check that regards the javax.inject package as invalid unless you are using Dagger:

Configure lint within build.gradle

  1. android {
  2. ...
  3. lintOptions {
  4. lintOptions { warning 'InvalidPackage' }
  5. }
  6. }

You can find more information on configuring annotations processors in the Android documentation.

Micronaut inject-java dependency uses Android Java 8 support features.