Annotation processing is a powerful tool for generating code for Android apps. In this tutorial, you’ll create one that generates RecyclerView adapters.
For the Where to Go From Here? section I would expect a link to other tutorials about packaging the generated modules. While having a processor is cool, how do you reuse one? Do you need to create two submodules and copy&paste the files everywhere?
How would the packaging work, a .jar or .aar file? Maybe some gradle magic? How can you make the packaged processor automatically import kotlinpoet?
Hi! Reusing an AP is just like reusing any other dependency - either pack and ship it directly (with :install Gradle command) or host is on a remote repo (like Jitpack or BinTray).
A JAR would be created if the modules were pure JVM libs, which these are not since they have Android-specific dependencies (RecyclerViews and such), hence the resulting package is an AAR (not that it really matters, though). The package processor will always automatically have KotlinPoet as it is specified as its dependency.
Hi! I see that you’ve answered your own question by now on SO. My initial guess would be that JDK version shouldn’t affect the availability of java.io nor anything javax, so I figured it’d be a caching issue. Have you tried clearing caches manually from AS, or it didn’t affect jdk.table.xml?
Hello Gordan.
I noticed that when I use a resource id as an annotation class attribute(e.g. @AdapterModel(R.layout.layout_person)) then Android Studio IDE displays warning: “Resource IDs will be non-final in Android Gradle Plugin version 5.0, avoid using them as annotation attributes”. I wonder if there is some workaround for this issue.
Best Regards