Skip to content

Instantly share code, notes, and snippets.

@shrikanthkr
Last active September 2, 2017 05:54
Show Gist options
  • Save shrikanthkr/8917d2698e0e481b7ba0c844439b50e9 to your computer and use it in GitHub Desktop.
Save shrikanthkr/8917d2698e0e481b7ba0c844439b50e9 to your computer and use it in GitHub Desktop.
Steps For adding annotation processor in android
  • Add two modules one for api and other for processor(Ensure its a java library) - There are conflicts in javax pacakges between android jar and jdk javax packages.
  • include apt plugin
apply plugin: 'com.neenbedankt.android-apt'

buildscript {
  repositories{
    mavenCentral()
   }

   dependencies{

    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'

   }

}
  • Use apt in dependencies
apt 'for.remote.projects:1.0.0'
apt project(':forLocalProjects')
  • Create meta inf

inside src/main

create resources directory

inside resources * create META-INF directory

inside META-INF * create services

inside services * create javax.annotation.processing.Processor

Give processor full class path in it

com.example.com.MyProcessor

To debug

./gradlew --no-daemon -Dorg.gradle.debug=true :app:clean :app:compileDebugJavaWithJavac

Add a remote run config and run after the above command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment