Skip to content

Commit a3243b8

Browse files
fix: Configure Android build for Java 17 compatibility
- Force Java 17 for all Android subprojects in root build.gradle - Override Capacitor's Java 21 requirement with Java 17 - Exclude .gz files from Android packaging to avoid duplicate resources - Fixes build errors with Capacitor 6 and Java 17 Android APK builds now working: build/android/ai-mate-debug.apk (17MB)
1 parent 3af8f8e commit a3243b8

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

android/app/build.gradle

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ android {
44
namespace "com.fiftyeight.aimate"
55
compileSdk rootProject.ext.compileSdkVersion
66

7-
compileOptions {
8-
sourceCompatibility JavaVersion.VERSION_17
9-
targetCompatibility JavaVersion.VERSION_17
10-
}
117
defaultConfig {
128
applicationId "com.fiftyeight.aimate"
139
minSdkVersion rootProject.ext.minSdkVersion
@@ -18,7 +14,8 @@ android {
1814
aaptOptions {
1915
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
2016
// Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
21-
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
17+
// Exclude .gz files to avoid duplicate resource errors with Blazor WASM
18+
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~:*.gz'
2219
}
2320
}
2421

@@ -71,6 +68,15 @@ dependencies {
7168

7269
apply from: 'capacitor.build.gradle'
7370

71+
// Override Capacitor's Java 21 requirement with Java 17
72+
// Must be after capacitor.build.gradle to take precedence
73+
android {
74+
compileOptions {
75+
sourceCompatibility JavaVersion.VERSION_17
76+
targetCompatibility JavaVersion.VERSION_17
77+
}
78+
}
79+
7480
try {
7581
def servicesJSON = file('google-services.json')
7682
if (servicesJSON.text) {

android/build.gradle

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ allprojects {
2222
google()
2323
mavenCentral()
2424
}
25+
26+
// Force Java 17 for all subprojects (including Capacitor modules)
27+
afterEvaluate { project ->
28+
if (project.hasProperty('android')) {
29+
project.android {
30+
compileOptions {
31+
sourceCompatibility JavaVersion.VERSION_17
32+
targetCompatibility JavaVersion.VERSION_17
33+
}
34+
}
35+
}
36+
}
2537
}
2638

2739
task clean(type: Delete) {

0 commit comments

Comments
 (0)