From 79d1e841989c9c63757adc2a7f0d19e67cf103b9 Mon Sep 17 00:00:00 2001 From: Rui Moreira Mendes Date: Tue, 11 Aug 2026 16:22:48 +0100 Subject: [PATCH 1/2] fix(android-template): declare app/build.gradle dependency versions explicitly --- android-template/app/build.gradle | 7 +++++++ cli/src/tasks/migrate.ts | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/android-template/app/build.gradle b/android-template/app/build.gradle index 5ac536dc7..2081f3511 100644 --- a/android-template/app/build.gradle +++ b/android-template/app/build.gradle @@ -1,5 +1,12 @@ apply plugin: 'com.android.application' +def androidxAppCompatVersion = rootProject.ext.androidxAppCompatVersion +def androidxCoordinatorLayoutVersion = rootProject.ext.androidxCoordinatorLayoutVersion +def coreSplashScreenVersion = rootProject.ext.coreSplashScreenVersion +def junitVersion = rootProject.ext.junitVersion +def androidxJunitVersion = rootProject.ext.androidxJunitVersion +def androidxEspressoCoreVersion = rootProject.ext.androidxEspressoCoreVersion + android { namespace = "com.getcapacitor.myapp" compileSdk = rootProject.ext.compileSdkVersion diff --git a/cli/src/tasks/migrate.ts b/cli/src/tasks/migrate.ts index 843bf9629..ac5492174 100644 --- a/cli/src/tasks/migrate.ts +++ b/cli/src/tasks/migrate.ts @@ -553,6 +553,23 @@ async function updateAppBuildGradle(filename: string) { `, '', ); + + if (!replaced.includes('def androidxAppCompatVersion = rootProject.ext.androidxAppCompatVersion')) { + replaced = replaced.replace( + `apply plugin: 'com.android.application'\n\n`, + `apply plugin: 'com.android.application' + +def androidxAppCompatVersion = rootProject.ext.androidxAppCompatVersion +def androidxCoordinatorLayoutVersion = rootProject.ext.androidxCoordinatorLayoutVersion +def coreSplashScreenVersion = rootProject.ext.coreSplashScreenVersion +def junitVersion = rootProject.ext.junitVersion +def androidxJunitVersion = rootProject.ext.androidxJunitVersion +def androidxEspressoCoreVersion = rootProject.ext.androidxEspressoCoreVersion + +`, + ); + } + writeFileSync(filename, replaced, 'utf-8'); } From f54d221a7aa1a56e5d880c02f04aae6c547f3267 Mon Sep 17 00:00:00 2001 From: Rui Moreira Mendes Date: Tue, 11 Aug 2026 17:22:09 +0100 Subject: [PATCH 2/2] revert migrate.ts changes --- cli/src/tasks/migrate.ts | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/cli/src/tasks/migrate.ts b/cli/src/tasks/migrate.ts index ac5492174..843bf9629 100644 --- a/cli/src/tasks/migrate.ts +++ b/cli/src/tasks/migrate.ts @@ -553,23 +553,6 @@ async function updateAppBuildGradle(filename: string) { `, '', ); - - if (!replaced.includes('def androidxAppCompatVersion = rootProject.ext.androidxAppCompatVersion')) { - replaced = replaced.replace( - `apply plugin: 'com.android.application'\n\n`, - `apply plugin: 'com.android.application' - -def androidxAppCompatVersion = rootProject.ext.androidxAppCompatVersion -def androidxCoordinatorLayoutVersion = rootProject.ext.androidxCoordinatorLayoutVersion -def coreSplashScreenVersion = rootProject.ext.coreSplashScreenVersion -def junitVersion = rootProject.ext.junitVersion -def androidxJunitVersion = rootProject.ext.androidxJunitVersion -def androidxEspressoCoreVersion = rootProject.ext.androidxEspressoCoreVersion - -`, - ); - } - writeFileSync(filename, replaced, 'utf-8'); }