Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Thin Capacitor wrapper around the OneSignal Android SDK. Designed to be consumed

## Kotlin / AGP toolchain

The plugin module declares its own `buildscript` classpath for the Android Gradle Plugin and the Kotlin Gradle Plugin. This is required because Capacitor 7's host `build.gradle` does not classpath the Kotlin Gradle Plugin for sub-projects; without our own classpath the `kotlin-android` plugin would fail to resolve.
The plugin module declares its own `buildscript` classpath for the Android Gradle Plugin and the Kotlin Gradle Plugin. This is required because Capacitor 7's host `build.gradle` does not classpath the Kotlin Gradle Plugin for sub-projects. Under AGP 8 the module applies `kotlin-android`; under AGP 9 it uses AGP's built-in Kotlin support instead.

Defaults live in [`gradle/libs.versions.toml`](gradle/libs.versions.toml):

Expand All @@ -15,7 +15,7 @@ Host apps that need to pin a different Kotlin compiler can do so via any standar

## SDK levels

`compileSdk`, `minSdk`, and `targetSdk` default to the Capacitor 8 floors (36 / 24 / 36). Host apps override any of them by setting the matching `<name>Version` property through any Gradle property source (`rootProject.ext`, `gradle.properties`, or `-P`) — Capacitor 7 host apps that ship with `variables.gradle` defaults of 35 / 23 / 35 will continue to take precedence over the catalog defaults.
`compileSdk` and `minSdk` default to the Capacitor 8 floors (36 / 24). Host apps override either value by setting the matching `<name>Version` property through any Gradle property source (`rootProject.ext`, `gradle.properties`, or `-P`). The consuming application owns `targetSdk`; AGP 9 no longer exposes it in the Android library DSL.

## Library versions

Expand Down
26 changes: 12 additions & 14 deletions android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -99,33 +99,31 @@ extra["junitVersion"] = junitVersion
extra["androidxAppCompatVersion"] = androidxAppCompatVersion

apply(plugin = "com.android.library")
apply(plugin = "kotlin-android")

configure<com.android.build.gradle.LibraryExtension> {
val androidPluginVersion = com.android.build.api.AndroidPluginVersion.getCurrent()

// AGP 9 provides Kotlin support itself, while AGP 8 hosts still require this plugin.
if (androidPluginVersion < com.android.build.api.AndroidPluginVersion(9, 0)) {
apply(plugin = "kotlin-android")

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
compilerOptions.jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
}
}

configure<com.android.build.api.dsl.LibraryExtension> {
namespace = "com.onesignal.capacitor"
compileSdk = intPropertyOrCatalog("compileSdkVersion", "compileSdk")
defaultConfig {
minSdk = intPropertyOrCatalog("minSdkVersion", "minSdk")
@Suppress("DEPRECATION")
targetSdk = intPropertyOrCatalog("targetSdkVersion", "targetSdk")
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
compilerOptions.jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
}

repositories {
google()
mavenCentral()
Expand Down
1 change: 0 additions & 1 deletion android/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ junit = "4.13.2"
kotlin = "2.2.20"
minSdk = "24"
onesignal = "5.9.8"
targetSdk = "36"

[libraries]
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidxAppCompat" }
Expand Down
2 changes: 1 addition & 1 deletion examples/demo-no-location/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ android {
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/demo-nx/apps/shop/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ android {
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ android {
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
// Sign release with Android's auto-generated debug keystore so
// `assembleRelease` produces an installable app-release.apk for
// Appium E2E. Don't ship release builds to users this way.
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/android/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
agp = "8.13.0"
agp = "9.1.1"
kotlin = "2.1.20"
googleServices = "4.4.4"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion examples/demo_cap7/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ android {
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/demo_pods/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ android {
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
}
Expand Down
Loading