Skip to content

fix: resolve Android dependencies on AGP 9 - #1087

Merged
christoph-sg merged 3 commits into
mainfrom
ch/fix-cme
Nov 19, 2026
Merged

christoph-sg merged 3 commits into
mainfrom
ch/fix-cme

Conversation

@christoph-sg

@christoph-sg christoph-sg commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

On AGP 9, scipPrintDependencies crashed with a ConcurrentModificationException, because resolving a configuration adds a new one to the project's configuration list. Iterating over a copy fixes that. The configuration AGP adds there (androidApis, holding android.jar) has no Maven coordinates, so skipping it loses nothing.

Once the task ran, every Android variant classpath that includes another Android module still failed to resolve, and the ones that did resolve listed .aar files, which the aggregator ignores. AGP's variant configurations don't request an artifact type, AGP always resolves them through an artifact view. We now do the same for configurations carrying AGP's build type attribute, asking for android-classes-jar, which gives the same transformed jars the Kotlin compile uses. On the AGP 9.1 / Kotlin 2.3 repro fixture from #864 this goes from 29 skipped configurations to none, and AndroidX symbols now get Maven coordinates.

Partially fixes #864: auto-mode still doesn't trigger Android compile tasks, so Android projects need an explicit build command like scip-java index -- clean scipPrintDependencies compileDebugKotlin.

This avoids a ConcurrentModificationException, when resolving a configuration adds a new one to the
project configuration list.
AGP's variant configurations, such as debugCompileClasspath, don't request an artifact type.
Resolving them directly fails as soon as they include another Android module, and otherwise yields
.aar files, which the aggregator ignores. Request the android-classes-jar artifacts AGP compiles
against instead, so Android dependencies get Maven coordinates.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1e90a-ee48-77ee-acba-7dd64721effc
Co-authored-by: Amp <amp@ampcode.com>
@christoph-sg christoph-sg changed the title fix: iterate over a copy of project configurations fix: resolve Android dependencies on AGP 9 Nov 19, 2026

@chrapkowski-sg chrapkowski-sg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix. Matching on the BuildTypeAttr attribute and requesting android-classes-jar to mirror AGP's own compile path makes sense to me. Two small suggestions:

1. Make the artifact view lenient. The old branch never transformed anything, but this view is strict, so a single artifact that has no transform chain to android-classes-jar (or a transform that fails) now makes us skip every dependency in that configuration. I haven't reproduced this; candidates would be a klib/zip artifact, a malformed AAR, or AARs on the annotation-processor classpath, which AGP itself never resolves this way. Something like this would keep the rest of the jars:

view.lenient(true);
...
ArtifactCollection artifacts = conf.getIncoming().artifactView(...).getArtifacts();
artifacts.getFailures().forEach(failure ->
    getLogger().warn("Skipping artifact in '" + conf.getName() + "': " + failure.getMessage()));
artifacts.forEach(artifact -> { ... });

2. Project dependencies are now dropped, but only on Android configurations. Before this change, an Android variant whose project dependencies were all Java modules resolved fine and wrote a line like group core unspecified <classes dir>. The ModuleComponentIdentifier filter now drops those, while the non-Android branch still writes them. The impact is probably small, since a published sibling writes its own line from its own task. Still, could you add a short comment on the filter (or a sentence in the description) so it's clear this asymmetry is intended?

A single artifact that can't be transformed to android-classes-jar now only skips itself, with a
warning, instead of the whole configuration. Also note why the view leaves out project dependencies.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1e90a-ee48-77ee-acba-7dd64721effc
Co-authored-by: Amp <amp@ampcode.com>
@christoph-sg
christoph-sg merged commit 3d10051 into main Nov 19, 2026
29 checks passed
@christoph-sg
christoph-sg deleted the ch/fix-cme branch November 19, 2026 13:40
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.

Kotlin 2.3 / AGP 9 / Gradle 9 unsupported — both auto-mode and semanticdb-kotlinc fail

2 participants