I am currently working an Android app (on Android Studio, using mainly Java).
I want to generate javadoc (using the Tools -> Generate menu).
Following this other post (Android Studio Javadoc: Cannot find symbol), I added the following code to my build.gradle :
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
Unfortunately this does not work. When I try to generate the javadoc, I have the following errors (and a lot more) :
error: cannot find symbol
import android.Manifest;
...
error: package android.compat.annotation does not exist
import android.compat.annotation.UnsupportedAppUsage;
...
error: package android.compat.annotation does not exist
import android.compat.annotation.UnsupportedAppUsage;
...
I tried adding the following to the gradle file :
afterEvaluate {
javadoc.classpath += files(android.libraryVariants.collect { variant ->
variant.javaCompileProvider.get().classpath.files
})
}
But with this added, I get an error when pressing sync gradle :
> Could not get unknown property 'libraryVariants' for extension 'android' of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.