Android Gradle javadoc annotation does not exists Android Gradle javadoc annotation does not exists android android

Android Gradle javadoc annotation does not exists


This fixed various similar errors for me:

Add the following to build.gradle:

configurations {    javadocDeps}dependencies {    compile 'com.android.support:support-annotations:22.2.0'    javadocDeps 'com.android.support:support-annotations:22.2.0'    androidTestCompile 'junit:junit:4.+'    androidTestCompile 'com.jayway.android.robotium:robotium-solo:+'}

In the JavaDoc Task add this line:

classpath += configurations.javadocDeps


Just add this line in your javadoc task (notice the last part: + configurations.compile):

classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + configurations.compile

The last part of the line makes sure the javadoc use the compile dependencies to resolve the classes it's using for javadoc. At this point, it shouldn't fail anymore.


Since the introduction of the api and implementation dependency configuration in Android Gradle 3.0.0, compile is deprecated. To include an implementation dependency in the javadoc classpath, I updated Loius CADs answer:

task javadoc(type: Javadoc) {    source = android.sourceSets.main.java.srcDirs    configurations.implementation.setCanBeResolved(true)    classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + configurations.implementation}

I don't expect this to be the cleanest solution possible. There probably is a reason why configuration.implementation is not resolvable by default.