I am developing an annotation processor using Android Studio. My project
has three modules:
*anno-api*- This contains that API - i.e, just defines the annotations and
some constants
*anno-processor* - This has a compile dependency on anno-api and it
contains the class extending AbstractProcessor
*sample* - This demonstrates how to use the annotations.
The setup is working just fine. Now, I want to do better validation in my
Annotation Processor. For this, both anno-api and anno-processor need to
have access to the Android API.
For example, consider this annotation. It has a method of type Class but I
want to restrict this to just sub-classes of Activity.
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
public @interface AwesomeActivity {
Class<? extends android.app.Activity> base();
}
How do I go about doing this? *How do I tell anno-api and anno-processor to
depend on Android classes?*
Here are the things I tried:
1) I tried making both anno-api and anno-processor as Android Library
projects.
2) I tried adding android.jar in the lib/ folder of the anno-api project
and adding a dependency to the JAR file in build.gradle.
In both cases the I end up with compile errors in my Annotation Processor.
Basically it refuses to recognize the javax.annotation.* and other such
classes. I suspect that at this point, only the classes present in
android.jar are recognized.
--
You received this message because you are subscribed to the Google Groups
"adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.