fix(android): Auto-detect Java/SDK and fix KAPT Java 17+ compatibility

- Auto-detect Java from Android Studio (JBR/JRE) or system PATH
- Auto-detect Android SDK from common locations or local.properties
- Auto-write SDK location to local.properties for Gradle
- Add KAPT JVM args to gradle.properties for Java 17+ module access
- Fix Java version command quoting for paths with spaces
- Comment out DailyNotificationPlugin (Java class not implemented)

Eliminates manual JAVA_HOME/ANDROID_HOME setup requirements and fixes
KAPT compilation errors when using Java 17+.

Author: Matthew Raymer
This commit is contained in:
Matthew
2026-02-02 02:06:44 -08:00
parent 1345118b79
commit d0878507a6
9 changed files with 173 additions and 8 deletions

View File

@@ -18,6 +18,7 @@ dependencies {
implementation project(':capacitor-share')
implementation project(':capacitor-status-bar')
implementation project(':capawesome-capacitor-file-picker')
implementation project(':timesafari-daily-notification-plugin')
}

View File

@@ -56,8 +56,8 @@
<receiver
android:name="com.timesafari.dailynotification.NotifyReceiver"
android:enabled="true"
android:exported="false">
</receiver>
android:exported="false"
/>
<receiver
android:name="com.timesafari.dailynotification.BootReceiver"
@@ -89,7 +89,7 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
<!-- Daily Notification Plugin Permissions -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />

View File

@@ -35,6 +35,10 @@
"pkg": "@capawesome/capacitor-file-picker",
"classpath": "io.capawesome.capacitorjs.plugins.filepicker.FilePickerPlugin"
},
{
"pkg": "@timesafari/daily-notification-plugin",
"classpath": "com.timesafari.dailynotification.DailyNotificationPlugin"
},
{
"pkg": "SafeArea",
"classpath": "app.timesafari.safearea.SafeAreaPlugin"

View File

@@ -68,7 +68,8 @@ public class MainActivity extends BridgeActivity {
registerPlugin(SharedImagePlugin.class);
// Register DailyNotification plugin
registerPlugin(com.timesafari.dailynotification.DailyNotificationPlugin.class);
// TODO: Uncomment when DailyNotificationPlugin Java class is implemented
// registerPlugin(com.timesafari.dailynotification.DailyNotificationPlugin.class);
// Initialize SQLite
//registerPlugin(SQLite.class);

View File

@@ -22,6 +22,9 @@ allprojects {
google()
mavenCentral()
}
// Note: KAPT JVM arguments for Java 17+ compatibility are configured in gradle.properties
// The org.gradle.jvmargs setting includes --add-opens flags needed for KAPT
}
task clean(type: Delete) {

View File

@@ -28,3 +28,6 @@ project(':capacitor-status-bar').projectDir = new File('../node_modules/@capacit
include ':capawesome-capacitor-file-picker'
project(':capawesome-capacitor-file-picker').projectDir = new File('../node_modules/@capawesome/capacitor-file-picker/android')
include ':timesafari-daily-notification-plugin'
project(':timesafari-daily-notification-plugin').projectDir = new File('../node_modules/@timesafari/daily-notification-plugin/android')

View File

@@ -9,7 +9,8 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# Added --add-opens flags for KAPT compatibility with Java 17+
org.gradle.jvmargs=-Xmx1536m --add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit