Would Annotation Processing Tool work in Kotlin?

I'm trying to migrate some Android Java code that uses Android Annotations[1]. AA does "injection" by generating plumbing code in compile time. e.g. for a MyActivity class with some anotated fields, it generates a MyActivity_ class. The class generation uses Annotation Processing Tool [2] as explained in AA's doc [3].

I guess APT won’t work in Kotlin as Kotlin has its own compiler, right?

[1] http://androidannotations.org/
[2] http://docs.oracle.com/javase/6/docs/technotes/guides/apt/index.html
[3] https://github.com/excilys/androidannotations/wiki/HowItWorks

For what I know about APT, it shouldn't work with Kotlin.

I guess so too. thx for the clarification.

As a workaround, I put the logic in a Kotlin parent class with abstract getter methods, and have a Java subclass that does the APT “injection” and implements the getters. There are some boilerplate code but I guess that’s the best way.

Any updates on supporting APT? There are lot of nice (and very useful) modern Android frameworks that depend on APT. I've been looking into using Kotlin as an alternative language for Android development and this is the biggest blocker that I've stumbled upon so far. Someone has already expressed his sentiment about the lack of APT support in Kotlin: http://mingfai.ma/post/51467931469/giving-up-kotlin-as-a-java-language-alternative-for and I feel the same way

Thanks mentioning my link. Just fixed a few grammer in that the first few paragraphs to make it slightly more readable. i guess no one read more than a few paragraphs so don't bother to fix more. :-)

Kotlin uses a different compiler, so the APT support is talking about a completely new implementation that follow the APT spec. I suppose it will take a signficiant effort. To my understanding, the strongest driven force of Kotlin development is to to apply it to Intellij IDEA or other JetBrains products. And they don’t seem to build Android stuff, and even if they do, they may not use those APT-based frameworks.

That was my initial reaction too - Kotlin not being targeted towards Android development but that'd be a loss to both the community and JetBrains itself. Given how popular Android platform is and how awesome Kotlin is, I can only imagine the popularity of Kotlin if developers can seamlessly use it. I got hopeful after seeing couple of blog posts and some offical samples on Android+Kotlin integration so decided to get an update on this. I hope that they will find some middle ground to make it as seemless as possible to use Kotlin for Android development. Fingers crossed!

Edit: Just realized that you were probably the one who asked this question in the first place and I added a link to your blog post without knowing. Internet works in a funny way :slight_smile:

Big +1 here, that's very disappointing news.

It’s unclear when Java 8 support will be available on Android so Kotlin could really own the development space on Android and become the main language for the next few years. This is especially relevant since Android Studio, built on IDEA, seems to be the direction where Android development is headed.

Andrey and team, please consider making Android support a high priority for Kotlin, this could really help the language break through.

You are right. Though it may be technically possible, supporting APT in Kotlin compiler seems to require huge efforts.

I use Kotlin with Android - although I think APT support would be nice, I don't think it's a deal breaker.