Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android javax.annotation.processing Package missing

I would like to do some annotation processing based on the example in the following link: http://www.zdnetasia.com/writing-and-processing-custom-annotations-part-3-39362483.htm.

However, I would like to implement this in my Android project, and it seems I cannot use the package with the android platform. Do I need to add an external jar or is there something I'm missing?

Thanks.

like image 570
srowley Avatar asked Mar 10 '12 22:03

srowley


3 Answers

The javax.annotation.processing package is not included in Android. You don't need to include this inside your compiled app module. You just need this dependency for your compiler/processor module during build time. Therefore, inside your app's build.gradle you should add the following after including your annotation processor:

provided 'org.glassfish:javax.annotation:10.0-b28'
like image 135
Brian Attwell Avatar answered Nov 07 '22 05:11

Brian Attwell


There is a much easier way if you use Android Studio / Gradle.

I found the following looking through the answers of the question How do I add javax.annotation.Generated to Java SE 5?:

For a Gradle build the dependency should be

compile 'org.glassfish:javax.annotation:10.0-b28'

like image 18
Dirk Avatar answered Nov 07 '22 06:11

Dirk


The javax.annotation.processing package is not included in Android, but the Android VM team describes how to include extra javax packages here - it might be applicable to your question.

like image 11
Jens Avatar answered Nov 07 '22 06:11

Jens