0

I have a simple annotation in my processor like following:

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.TYPE) @Retention(RetentionPolicy.CLASS)
public @interface BundleBuilder
{
    // ...
}

This works in java files but as soon as I convert my file to kotlin, the import of the annotation is not working anymore. Why?

enter image description here

What do I need to change to get his annotation working in kotlin as well? From the docs I can see that kotlin is 100% compatible with java annotations so I'm a little bit confused here what's the problem... I would understand if the processor is not working and needs to be adjusted to work with kotlin, but I don't know why the import itself does not work...

The library I'm talking about is here: https://github.com/MFlisar/BundleArgs

1 Answer 1

2

I think you should use kapt for annotation processing in your build.gradle. After all, clean and rebuild your project so.

apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

//...

dependencies {
    compileOnly 'com.github.MFlisar.BundleArgs:bundleargs-annotation:1.3'
    kapt 'com.github.MFlisar.BundleArgs:bundleargs-processor:1.3'
}

repositories {
    maven { url "https://jitpack.io" }
}
Sign up to request clarification or add additional context in comments.

3 Comments

I'm using kapt everywhere already for quite some time, this is not the problem, sadly...
I do above in a sample project, no problem happened and BundleBuilder worked well! :-\
Try to Invalidate caches and restart the AndroidStudio.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.