Skip to content

Commit 96e72ca

Browse files
ADFA-2602: Correct version references in plugin docs and metadata comments (#1648)
* ADFA-2602: Correct version references in plugin docs and metadata comments PLUGIN_AUTHORING.md told plugin authors to request AGP 8.11.0 and Kotlin 1.9.22 for an on-device build. The harvested localMvnRepository now ships AGP 9.3.1 and Kotlin 2.3.21, so those instructions produced an unresolvable build. The apiVersion/languageVersion pins in common, eventbus-events, idetooltips and plugin-api stay at 2.0. Their comments named 1.9.22 as the reason, which no longer holds; the real invariant is that the jar must stay readable by every supported on-device compiler, including a device still on an older bundled toolchain after a KOTLIN_VERSION bump. Reworded to say that instead of naming a version that will keep going stale. * ADFA-2602: Point plugin docs at org.adfa.constants for on-device versions The on-device localMvnRepository ships AGP 9.3.1, Gradle 9.6.1 and Kotlin 2.3.21, not AGP 8.13.1 / Kotlin 2.3.0. AGP 9 also refuses org.jetbrains.kotlin.android and takes its compiler from the kotlin-gradle-plugin jar on the root buildscript classpath, so the documented root snippet would have failed to configure. Name the constants that pin these versions, so the doc stops going stale on every bump rather than being corrected after the fact. * ADFA-2602: Point the on-device SDK at build-tools 36.0.0 AGP 9.3.1 hard-requires build-tools >= 36.0.0, so `BUILD_TOOLS_VERSION` moves to 36.0.0. This drives `BUILD_TOOLS_DIR` and therefore the `android.aapt2FromMavenOverride` path that GradleBuildService passes to every build. This must land together with an asset that actually contains `build-tools/36.0.0`; on its own it points the IDE at a directory that does not exist yet. The matching dev-assets pipeline change and the platform-tools port that builds those binaries from android-16.0.0_r4 are the other two pieces. Also drop the build-tools version from the suppressed aapt2 warning. That entry is matched with `contains()` against the full override path, so pinning 35.0.0 meant the bump would silently stop matching and resurface an experimental-option warning in Build Output on every user build. Claude-Session: https://claude.ai/code/session_017HGpMsUzZ5wxCfMtDZ2HGP * ADFA-3078: Search the on-device Maven repo before the remote ones Offline builds failed unless the user turned on the --offline flag, which defeats the point of an offline-first IDE. The on-device repo was registered last. Templates declare gradlePluginPortal(), google() and mavenCentral() first, and this plugin appended with `maven { it.url = uri }`. With no network, dl.google.com fails DNS, and Gradle treats a repository *error* as fatal rather than falling through to the next repository the way it does for a 404. Resolution therefore died at google() and never reached the local repo. --offline worked only because it skips remote repositories entirely. The artifacts were never missing: the AGP plugin marker, kotlin-build-tools-compat and kotlin-build-tools-impl are all present in localMvnRepository on device. Inserting at index 0 instead of appending fixes all four injection points (pluginManagement, dependencyResolutionManagement, and the settings and project buildscript blocks). Verified on a Pixel 9 Pro emulator in airplane mode with offlineMode=false, the Gradle modules-2 cache deleted, and a brand new Empty Activity Kotlin project whose settings.gradle.kts was left untouched: sync reaches "Project initialized" and the build produces app-debug.apk. Both failed under identical conditions before this change. A warm module cache masks the bug, so retests need the cache cleared. Ships in the APK, not the assets zip, so no asset rebuild is required. Claude-Session: https://claude.ai/code/session_017HGpMsUzZ5wxCfMtDZ2HGP --------- Co-authored-by: Daniel Alome <astrocoder007@gmail.com>
1 parent bcb5da2 commit 96e72ca

8 files changed

Lines changed: 39 additions & 20 deletions

File tree

app/src/main/java/com/itsaky/androidide/ui/EditorBottomSheet.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,10 @@ class EditorBottomSheet
518518

519519
private val suppressedGradleWarnings =
520520
listOf(
521-
"The option setting 'android.aapt2FromMavenOverride=/data/data/com.itsaky.androidide/files/home/android-sdk/build-tools/35.0.0/aapt2' is experimental",
521+
// Matched with contains(), so the build-tools version is deliberately left
522+
// out: the path moves with Environment.BUILD_TOOLS_VERSION and a hardcoded
523+
// version silently stops matching, resurfacing the warning to users.
524+
"The option setting 'android.aapt2FromMavenOverride=",
522525
"The org.gradle.api.plugins.BasePluginConvention type has been deprecated.",
523526
"The org.gradle.api.plugins.Convention type has been deprecated.",
524527
"The BasePluginExtension.archivesBaseName property has been deprecated.",

common/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ android {
1212
kotlin {
1313
compilerOptions {
1414
// This module's classes ship in the plugin-api coordinate that on-device plugins
15-
// compile against, so emit metadata the on-device Kotlin (1.9.22) can read (<= 2.0.0).
15+
// compile against, so emit metadata every supported on-device Kotlin can read (<= 2.0.0).
1616
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
1717
languageVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
1818
}

common/src/main/java/com/itsaky/androidide/utils/Environment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public final class Environment {
4646
private static final String ANDROIDIDE_PROJECT_CACHE_DIR = SharedEnvironment.PROJECT_CACHE_DIR_NAME;
4747
private static final String DATABASE_NAME = "documentation.db";
4848

49-
public static final String BUILD_TOOLS_VERSION = "35.0.0";
49+
public static final String BUILD_TOOLS_VERSION = "36.0.0";
5050

5151
public static final String PLUGIN_API_JAR_RELATIVE_PATH = "libs/plugin-api.jar";
5252

docs/PLUGIN_AUTHORING.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ in `build.gradle.kts`:
3939
```kotlin
4040
plugins {
4141
id("com.android.application") version "8.8.2"
42-
id("org.jetbrains.kotlin.android") version "2.1.21"
42+
id("org.jetbrains.kotlin.android") version "2.3.0"
4343
id("com.itsaky.androidide.plugins.build")
4444
}
4545

@@ -66,21 +66,31 @@ against — the `:plugin-api` module plus `common`, `eventbus-events`, and
6666
`idetooltips`. The builder plugin applied above resolves the same way, from the
6767
injected `com.itsaky.androidide.plugins.build` `1.0.0` marker.
6868

69-
#### Building on-device (offline) pins the AGP/Kotlin versions
69+
#### Building on-device (offline) pins the AGP/Kotlin/Gradle versions
7070

71-
The `plugins {}` example above uses AGP `8.8.2` / Kotlin `2.1.21` — the versions the
72-
dev/CI repo resolves online. A plugin built **on-device** resolves AGP and the Kotlin
73-
Gradle plugin from the harvested on-device `localMvnRepository`, which currently ships
74-
only **AGP `8.11.0`** and **Kotlin `1.9.22`**. Request those versions for an on-device
75-
build, or offline resolution of the build plugins fails.
71+
The `plugins {}` example above uses AGP `8.8.2` / Kotlin `2.3.0` — the versions the
72+
dev/CI repo resolves online. A plugin built **on-device** resolves its build plugins from
73+
the harvested on-device `localMvnRepository`, which ships only the versions pinned in
74+
`org.adfa.constants``ANDROID_GRADLE_PLUGIN_VERSION`, `KOTLIN_VERSION` and
75+
`GRADLE_DISTRIBUTION_VERSION`, currently **AGP `9.3.1`**, **Kotlin `2.3.21`** and
76+
**Gradle `9.6.1`**. Request those, or offline resolution of the build plugins fails. That
77+
constants file is authoritative; the numbers here are a snapshot of it.
7678

77-
Also declare AGP `apply false` in the **root** `build.gradle.kts` (as the standard CoGo
78-
project template does):
79+
AGP 9 compiles Kotlin itself and **refuses** the `org.jetbrains.kotlin.android` plugin, so
80+
an on-device build drops it and pins Kotlin through the `kotlin-gradle-plugin` jar on the
81+
**root** buildscript classpath, which is where AGP 9 takes its compiler from. Declare AGP
82+
`apply false` in the same root file (as the standard CoGo project template does):
7983

8084
```kotlin
85+
buildscript {
86+
dependencies {
87+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.3.21")
88+
}
89+
}
90+
8191
plugins {
82-
id("com.android.application") apply false version "8.11.0"
83-
id("com.android.library") apply false version "8.11.0"
92+
id("com.android.application") apply false version "9.3.1"
93+
id("com.android.library") apply false version "9.3.1"
8494
}
8595
```
8696

eventbus-events/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ android {
2929
kotlin {
3030
compilerOptions {
3131
// This module's classes ship in the plugin-api coordinate that on-device plugins
32-
// compile against, so emit metadata the on-device Kotlin (1.9.22) can read (<= 2.0.0).
32+
// compile against, so emit metadata every supported on-device Kotlin can read (<= 2.0.0).
3333
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
3434
languageVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
3535
}

gradle-plugin/src/main/java/com/itsaky/androidide/gradle/COTGSettingsPlugin.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,13 @@ private fun RepositoryHandler.addMavenRepoIfMissing(
116116
logger: Logger,
117117
uri: URI,
118118
) {
119-
if (none { it is MavenArtifactRepository && it.url == uri }) {
120-
logger.info("Adding maven repository: $uri")
121-
maven { it.url = uri }
119+
if (any { it is MavenArtifactRepository && it.url == uri }) {
120+
return
122121
}
122+
123+
logger.info("Adding maven repository: $uri")
124+
val repo = maven { it.url = uri }
125+
126+
remove(repo)
127+
add(0, repo)
123128
}

idetooltips/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ android {
1212
kotlin {
1313
compilerOptions {
1414
// This module's classes ship in the plugin-api coordinate that on-device plugins
15-
// compile against, so emit metadata the on-device Kotlin (1.9.22) can read (<= 2.0.0).
15+
// compile against, so emit metadata every supported on-device Kotlin can read (<= 2.0.0).
1616
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
1717
languageVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
1818
}

plugin-api/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ android {
2222
kotlin {
2323
compilerOptions {
2424
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
25-
// Emit metadata the on-device Kotlin compiler (1.9.22) can read (<= 2.0.0).
25+
// Emit metadata every supported on-device Kotlin compiler can read (<= 2.0.0), so a
26+
// device still on an older bundled toolchain keeps working after a KOTLIN_VERSION bump.
2627
// This jar ships in the plugin-api coordinate on-device plugins compile against.
2728
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
2829
languageVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)

0 commit comments

Comments
 (0)