Generate Javadoc from Android Studio or gradlew

I realize there are quite a few questions on here already about this, but they all appear to be outdated past the point of being helpful. The two most upvoted are here:

  • Using gradlew
  • Using Android Studio

Even for a brand new empty project on Android Studio Koala (2024.1.1) I cannot create a Javadoc with Tools–Generate Javadoc. This yields errors as documented here. This seems to have been broken for quite some time and not very high on the todo list.

Fine, so then how do I generate it with gradle as they claim is possible as a workaround?

Lets try the most upvoted answer on SO so far, i.e.

task javadoc(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    destinationDir = file("../javadoc/")
    failOnError false
}

This will yield:

* What went wrong:
Execution failed for task ':myapplication:javadoc'.
> path may not be null or empty string. path=''

Add println("classpath=" + android.getBootClasspath().join(File.pathSeparator)) after defining source above, and you will see the classpath is empty. It appears the project.files is defined here for Gradle 7.7 (used by default on newest Android Studio). There is claims

paths – The paths to the files. May be empty.

So the

path may not be null or empty string. path=”

error must be thrown somewhere else. Still trying to figure exactly where that error is thrown, but that specific question is tracked my related question here

So based on comments from the above mentioned question, I have reason to believe the android object/block is defined here. If that is so, then I don’t see any link to getBootClasspath() so I’m surprised this is not shown in the gradle error output. Android studio’s tooltip claims it resolves to com.android.build.gradle.BaseExtension, but I see no reference to BaseExtension in the Android Gradle Plugin API.

In fact, the only mention of getBootClasspath I can find is here but this is some strange URL with null in it, so trying to find this from the normal API docs seems impossible. I also cannot find if this method ever existed in the past and was deprecated or what. Looking at the source and grep -R getBootClasspath . I see

./builder-model/src/main/java/com/android/builder/model/AndroidProject.java:    Collection<String> getBootClasspath();
./gradle/src/main/groovy/com/android/build/gradle/BasePlugin.groovy:        return AndroidBuilder.getBootClasspath(sdkParser);
./gradle/src/main/groovy/com/android/build/gradle/internal/model/DefaultAndroidProject.java:    public Collection<String> getBootClasspath() {
./builder/src/main/java/com/android/builder/AndroidBuilder.java: * {@link #getBootClasspath(SdkParser)}.
./builder/src/main/java/com/android/builder/AndroidBuilder.java:    public static List<String> getBootClasspath(@NonNull SdkParser sdkParser) {
./builder/src/main/java/com/android/builder/AndroidBuilder.java:        classpath.addAll(target.getBootClasspath());
./builder/src/main/java/com/android/builder/internal/FakeAndroidTarget.java:    public List<String> getBootClasspath() {
./gradle-model/src/test/java/com/android/build/gradle/model/AndroidProjectTest.java:        assertFalse("Non empty bootclasspath", model.getBootClasspath().isEmpty());

The only one of those that looked exposed to the API docs was ./gradle/src/main/groovy/com/android/build/gradle/BasePlugin.groovy so I looked there to find:

    public List<String> getRuntimeJarList() {
        SdkParser sdkParser = getLoadedSdkParser()
        return AndroidBuilder.getBootClasspath(sdkParser);
    }

So I tried defining my classpath as

classpath += project.files(android.getRuntimeJarList.join(File.pathSeparator))

which resulted in

* What went wrong:
A problem occurred evaluating project ':myapplication'.
> Could not get unknown property 'getRuntimeJarList' for extension 'android' of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.

Not at all the info I was seeking from that change, but happy to now know the actual resolution for android = com.android.build.gradle.internal.dsl.BaseAppModuleExtension So I tried to find the source for that, but there is no such BaseAppModuleExtension in ./gradle/src/main/groovy/com/android/build/gradle/internal/dsl/ of the source. find . -name "BaseAppModuleExtension" also returns empty. Now I’m lost. How can I find the definition or replacement for getBootClasspath if the thing gradlew tells me android is, does not exist? Furthermore, adding println("classtype: " + android.getClass()) to the task, results in classtype: class com.android.build.gradle.internal.dsl.BaseAppModuleExtension_Decorated

If this is all internal, how in the world am I supposed to know how to use it?

More fundamentally, I need to understand what classpath is. I don’t see it as listed method in the API, but the closest thing is setClassPath and getClassPath. So I tried:

task javadoc(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
    classpath = getClasspath()
    println("classpath=" + classpath.join(File.pathSeparator))
    destinationDir = file("../javadoc/")
    failOnError false
}

Again, classpath is empty. Ok, so apparently gradle doesn’t know the default classpath, so it likely lies within the android block somewhere as previously hinted.

Finally, I also tried the proposed solution given here and this runs without errors (after building the project to generate the R files) but then the javadoc directory is empty with no sign of errors.

I am at a loss for where to search next. I am troubled by how difficult generating javadocs is…

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật