Skip to content

Fix sources and javadoc generation for AGP 9.0 compatibility#157

Merged
Acconut merged 9 commits intodependabot/gradle/com.android.tools.build-gradle-9.0.1from
copilot/sub-pr-156
Mar 3, 2026
Merged

Fix sources and javadoc generation for AGP 9.0 compatibility#157
Acconut merged 9 commits intodependabot/gradle/com.android.tools.build-gradle-9.0.1from
copilot/sub-pr-156

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 3, 2026

AGP 9.0 removed several APIs previously used for sources and javadoc generation, causing project configuration to fail on every Gradle invocation (including assemble and check).

Changes

  • Sources and Javadoc: Replaced the manual afterEvaluate block (which relied on removed APIs android.getBootClasspath(), android.libraryVariants, and android.sdkDirectory) with AGP's built-in android.publishing.singleVariant API. AGP handles task creation and SDK classpath resolution internally:
// Before (broken in AGP 9) — manual afterEvaluate block with removed APIs
android.libraryVariants.all { variant -> ... }
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))

// After — AGP-native approach (4.1+)
android {
    publishing {
        singleVariant('release') {
            withSourcesJar()
            withJavadocJar()
        }
    }
}

Sources and javadoc are now automatically included in the release component and picked up by from components.release in the Maven publication.

  • compileSdk 33 → 34: android-33 platform is not present on the CI runner; android-34 is (consistent with example/build.gradle which already targets API 34).
  • gradle.properties: Removed android.defaults.buildfeatures.buildconfig=false, which was removed in AGP 9.0 and caused a deprecation warning.

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: Acconut <1375043+Acconut@users.noreply.github.com>
Copilot AI changed the title [WIP] Bump com.android.tools.build:gradle from 8.13.2 to 9.0.1 Bump Gradle wrapper to 9.1.0 for AGP 9.0.1 compatibility Mar 3, 2026
…e.txt

Co-authored-by: Acconut <1375043+Acconut@users.noreply.github.com>
Copilot AI changed the title Bump Gradle wrapper to 9.1.0 for AGP 9.0.1 compatibility Upgrade Gradle wrapper and fix AGP 9.0.1 compatibility issues Mar 3, 2026
Copilot stopped work on behalf of Acconut due to an error March 3, 2026 07:39
Co-authored-by: Acconut <1375043+Acconut@users.noreply.github.com>
Copilot AI changed the title Upgrade Gradle wrapper and fix AGP 9.0.1 compatibility issues Fix javadoc task: replace removed getBootClasspath() with AGP 7+ API Mar 3, 2026
Copilot AI and others added 4 commits March 3, 2026 08:03
Co-authored-by: Acconut <1375043+Acconut@users.noreply.github.com>
…ove removed gradle property

Co-authored-by: Acconut <1375043+Acconut@users.noreply.github.com>
…h instead

Co-authored-by: Acconut <1375043+Acconut@users.noreply.github.com>
Co-authored-by: Acconut <1375043+Acconut@users.noreply.github.com>
Copilot AI changed the title Fix javadoc task: replace removed getBootClasspath() with AGP 7+ API Fix javadoc task compatibility with AGP 9.0 Mar 3, 2026
@Acconut
Copy link
Copy Markdown
Member

Acconut commented Mar 3, 2026

@copilot Why is so much additional logic necessary for the javadoc task? How do modern projects handle this? Are there better and less verbose ways to generate javadoc?

…g API

Co-authored-by: Acconut <1375043+Acconut@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 3, 2026

@copilot Why is so much additional logic necessary for the javadoc task? How do modern projects handle this? Are there better and less verbose ways to generate javadoc?

The verbose manual approach was unnecessary. AGP 4.1+ provides android.publishing.singleVariant which accepts withSourcesJar() and withJavadocJar() — AGP then generates and wires up those tasks itself, handling the SDK classpath internally. No manual SDK path resolution or variant iteration needed.

Simplified in bafbdc4: removed the entire afterEvaluate block and replaced with 5 lines inside the android block:

publishing {
    singleVariant('release') {
        withSourcesJar()
        withJavadocJar()
    }
}

The from components.release in the publishing publication then automatically includes the sources and javadoc artifacts.

Copilot AI changed the title Fix javadoc task compatibility with AGP 9.0 Fix sources and javadoc generation for AGP 9.0 compatibility Mar 3, 2026
@Acconut Acconut marked this pull request as ready for review March 3, 2026 10:24
@Acconut Acconut merged commit bef5cd6 into dependabot/gradle/com.android.tools.build-gradle-9.0.1 Mar 3, 2026
3 checks passed
@Acconut Acconut deleted the copilot/sub-pr-156 branch March 3, 2026 10:24
Acconut added a commit that referenced this pull request Mar 3, 2026
* Bump com.android.tools.build:gradle from 8.13.2 to 9.0.1

Bumps com.android.tools.build:gradle from 8.13.2 to 9.0.1.

---
updated-dependencies:
- dependency-name: com.android.tools.build:gradle
  dependency-version: 9.0.1
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix sources and javadoc generation for AGP 9.0 compatibility (#157)

* Initial plan

* Update Gradle wrapper to 9.1.0 as required by AGP 9.0.1

Co-authored-by: Acconut <1375043+Acconut@users.noreply.github.com>

* Replace deprecated proguard-android.txt with proguard-android-optimize.txt

Co-authored-by: Acconut <1375043+Acconut@users.noreply.github.com>

* Fix getBootClasspath() compatibility with AGP 7+

Co-authored-by: Acconut <1375043+Acconut@users.noreply.github.com>

* Fix javadoc boot classpath for AGP 9 compatibility

Co-authored-by: Acconut <1375043+Acconut@users.noreply.github.com>

* Fix AGP 9 compatibility: boot classpath via env/local.properties, remove removed gradle property

Co-authored-by: Acconut <1375043+Acconut@users.noreply.github.com>

* Fix AGP 9: remove android.libraryVariants, use releaseCompileClasspath instead

Co-authored-by: Acconut <1375043+Acconut@users.noreply.github.com>

* Fix javadoc: update compileSdk to 34 and set failOnError=false

Co-authored-by: Acconut <1375043+Acconut@users.noreply.github.com>

* Simplify javadoc/sources generation using AGP singleVariant publishing API

Co-authored-by: Acconut <1375043+Acconut@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Acconut <1375043+Acconut@users.noreply.github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Acconut <1375043+Acconut@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants