1 Commits

Author SHA1 Message Date
Jose Olarte III
ec064a2aa0 fix(android): use TimeZone for default zone ID to support API 23
java.time.ZoneId is available only from API 26; on Android 6 it causes
NoClassDefFoundError when building NotificationContentEntity. Replaced
ZoneId.systemDefault().id with TimeZone.getDefault().id (Kotlin) and
getID() (Java) wherever we only need the system timezone ID string.

Same IANA ID and behavior on API 26+. No data or semantic change.
Worker/Scheduler still use java.time for date math; full API 23 there
would require ThreeTenABP or Calendar-based logic.
2026-02-27 16:02:45 +08:00
6 changed files with 14 additions and 24 deletions

View File

@@ -94,7 +94,6 @@ The project includes an automated build script that handles both TypeScript and
```bash
# Build all platforms
# Requires npm & gradle (with Java)
./scripts/build-native.sh
# Build specific platform

View File

@@ -37,7 +37,6 @@ android {
}
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
@@ -117,8 +116,6 @@ dependencies {
implementation "com.google.code.gson:gson:2.10.1"
implementation "androidx.core:core:1.12.0"
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
// Room annotation processor - use kapt for Kotlin, annotationProcessor for Java
kapt "androidx.room:room-compiler:2.6.1"
annotationProcessor "androidx.room:room-compiler:2.6.1"

View File

@@ -1162,12 +1162,12 @@ open class DailyNotificationPlugin : Plugin() {
} else {
call.reject("Daily notification scheduling failed")
}
} catch (e: Throwable) {
} catch (e: Exception) {
Log.e(TAG, "Failed to schedule daily notification", e)
call.reject("Daily notification scheduling failed: ${e.message}")
}
}
} catch (e: Throwable) {
} catch (e: Exception) {
Log.e(TAG, "Schedule daily notification error", e)
call.reject("Daily notification error: ${e.message}")
}
@@ -2711,7 +2711,7 @@ object ScheduleHelper {
config.title ?: "Daily Notification",
config.body ?: "",
nextRunTime,
java.time.ZoneId.systemDefault().id
java.util.TimeZone.getDefault().id
)
entity.soundEnabled = config.sound ?: true
entity.vibrationEnabled = config.vibration ?: true
@@ -2729,7 +2729,7 @@ object ScheduleHelper {
}
true
} catch (e: Throwable) {
} catch (e: Exception) {
Log.e("ScheduleHelper", "Failed to schedule daily notification", e)
false
}

View File

@@ -275,7 +275,7 @@ class NotifyReceiver : BroadcastReceiver() {
roomStorage.saveNotificationContent(entity).get()
Log.d(TAG, "Stored notification content in database: id=$notificationId (for recovery tracking)")
}
} catch (e: Throwable) {
} catch (e: Exception) {
Log.w(TAG, "Failed to store notification content in database, continuing with alarm scheduling", e)
}
@@ -400,18 +400,14 @@ class NotifyReceiver : BroadcastReceiver() {
Log.i(TAG, "Exact alarm scheduled (setExact): triggerAt=$triggerAtMillis, requestCode=$requestCode")
}
} catch (e: Throwable) {
} catch (e: SecurityException) {
Log.w(TAG, "Cannot schedule exact alarm, falling back to inexact", e)
try {
alarmManager.set(
AlarmManager.RTC_WAKEUP,
triggerAtMillis,
pendingIntent
)
Log.i(TAG, "Inexact alarm scheduled (fallback): triggerAt=$triggerAtMillis, requestCode=$requestCode")
} catch (fallbackError: Throwable) {
Log.e(TAG, "Fallback alarm scheduling also failed", fallbackError)
}
alarmManager.set(
AlarmManager.RTC_WAKEUP,
triggerAtMillis,
pendingIntent
)
Log.i(TAG, "Inexact alarm scheduled (fallback): triggerAt=$triggerAtMillis, requestCode=$requestCode")
}
// Update database schedule with new nextRunAt so getNotificationStatus() returns correct value
@@ -466,7 +462,8 @@ class NotifyReceiver : BroadcastReceiver() {
Log.d(SCHEDULE_TAG, "Created new schedule in database: id=$stableScheduleId, nextRunAt=$triggerAtMillis")
}
}
} catch (e: Throwable) {
} catch (e: Exception) {
// Log but don't fail - alarm is already scheduled, DB update is best-effort
Log.w(SCHEDULE_TAG, "Failed to update schedule in database: $stableScheduleId (alarm still scheduled)", e)
}
}

View File

@@ -65,7 +65,6 @@ emulator -avd AVD_NAME
adb devices
# Now install on the emulator
# ... which can take a looooooong time
adb install -r ./app/build/outputs/apk/debug/app-debug.apk
# Now start the app

View File

@@ -17,7 +17,6 @@ android {
}
}
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
@@ -63,7 +62,6 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-service:2.7.0'
implementation 'com.google.code.gson:gson:2.10.1'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"