Skip to content

Commit 6416c43

Browse files
committed
refactor(demo): migrate Android build to Kotlin DSL and remove LogManager
1 parent 2ec845e commit 6416c43

16 files changed

Lines changed: 226 additions & 485 deletions

examples/demo_pods/android/app/build.gradle

Lines changed: 0 additions & 54 deletions
This file was deleted.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
plugins {
2+
id("com.android.application")
3+
}
4+
5+
android {
6+
namespace = "com.onesignal.example"
7+
compileSdk = rootProject.extra["compileSdkVersion"] as Int
8+
defaultConfig {
9+
applicationId = "com.onesignal.example"
10+
minSdk = rootProject.extra["minSdkVersion"] as Int
11+
targetSdk = rootProject.extra["targetSdkVersion"] as Int
12+
versionCode = 1
13+
versionName = "1.0"
14+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
15+
androidResources {
16+
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
17+
// Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
18+
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
19+
}
20+
}
21+
buildTypes {
22+
release {
23+
isMinifyEnabled = false
24+
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
25+
}
26+
}
27+
}
28+
29+
repositories {
30+
flatDir {
31+
dirs("../capacitor-cordova-android-plugins/src/main/libs", "libs")
32+
}
33+
}
34+
35+
dependencies {
36+
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
37+
implementation(libs.androidx.appcompat)
38+
implementation(libs.androidx.coordinatorlayout)
39+
implementation(libs.androidx.core.splashscreen)
40+
implementation(project(":capacitor-android"))
41+
testImplementation(libs.junit)
42+
androidTestImplementation(libs.androidx.test.junit)
43+
androidTestImplementation(libs.androidx.test.espresso.core)
44+
implementation(project(":capacitor-cordova-android-plugins"))
45+
}
46+
47+
apply(from = "capacitor.build.gradle")
48+
49+
try {
50+
val servicesJSON = file("google-services.json")
51+
if (servicesJSON.readText().isNotEmpty()) {
52+
apply(plugin = "com.google.gms.google-services")
53+
}
54+
} catch (e: Exception) {
55+
logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
56+
}

examples/demo_pods/android/build.gradle

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
3+
buildscript {
4+
repositories {
5+
google()
6+
mavenCentral()
7+
}
8+
dependencies {
9+
classpath(libs.android.gradle.plugin)
10+
classpath(libs.kotlin.gradle.plugin)
11+
classpath(libs.google.services.plugin)
12+
13+
// NOTE: Do not place your application dependencies here; they belong
14+
// in the individual module build.gradle files
15+
}
16+
}
17+
18+
// Capture version catalog values outside the allprojects closure since `libs`
19+
// accessors are only available in the root script body.
20+
val minSdkVersion = libs.versions.minSdk.get().toInt()
21+
val compileSdkVersion = libs.versions.compileSdk.get().toInt()
22+
val targetSdkVersion = libs.versions.targetSdk.get().toInt()
23+
val androidxAppCompatVersion = libs.versions.androidxAppCompat.get()
24+
val cordovaAndroidVersion = libs.versions.cordovaAndroid.get()
25+
26+
allprojects {
27+
repositories {
28+
google()
29+
mavenCentral()
30+
}
31+
32+
// Expose version catalog values as project extras so the Capacitor-generated
33+
// Groovy modules (capacitor-cordova-android-plugins) can resolve them via
34+
// rootProject.ext.* without needing variables.gradle.
35+
extra["minSdkVersion"] = minSdkVersion
36+
extra["compileSdkVersion"] = compileSdkVersion
37+
extra["targetSdkVersion"] = targetSdkVersion
38+
extra["androidxAppCompatVersion"] = androidxAppCompatVersion
39+
extra["cordovaAndroidVersion"] = cordovaAndroidVersion
40+
}
41+
42+
tasks.register<Delete>("clean") {
43+
delete(rootProject.layout.buildDirectory)
44+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[versions]
2+
agp = "8.13.0"
3+
kotlin = "2.1.20"
4+
googleServices = "4.4.4"
5+
6+
compileSdk = "36"
7+
minSdk = "24"
8+
targetSdk = "36"
9+
10+
androidxActivity = "1.11.0"
11+
androidxAppCompat = "1.7.1"
12+
androidxCoordinatorLayout = "1.3.0"
13+
androidxCore = "1.17.0"
14+
androidxFragment = "1.8.9"
15+
androidxWebkit = "1.14.0"
16+
coreSplashScreen = "1.2.0"
17+
18+
junit = "4.13.2"
19+
androidxJunit = "1.3.0"
20+
androidxEspressoCore = "3.7.0"
21+
22+
cordovaAndroid = "14.0.1"
23+
24+
[libraries]
25+
android-gradle-plugin = { module = "com.android.tools.build:gradle", version.ref = "agp" }
26+
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
27+
google-services-plugin = { module = "com.google.gms:google-services", version.ref = "googleServices" }
28+
29+
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidxAppCompat" }
30+
androidx-coordinatorlayout = { module = "androidx.coordinatorlayout:coordinatorlayout", version.ref = "androidxCoordinatorLayout" }
31+
androidx-core-splashscreen = { module = "androidx.core:core-splashscreen", version.ref = "coreSplashScreen" }
32+
33+
junit = { module = "junit:junit", version.ref = "junit" }
34+
androidx-test-junit = { module = "androidx.test.ext:junit", version.ref = "androidxJunit" }
35+
androidx-test-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "androidxEspressoCore" }

examples/demo_pods/android/settings.gradle

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
include(":app")
2+
include(":capacitor-cordova-android-plugins")
3+
project(":capacitor-cordova-android-plugins").projectDir = file("./capacitor-cordova-android-plugins/")
4+
5+
apply(from = "capacitor.settings.gradle")

examples/demo_pods/android/variables.gradle

Lines changed: 0 additions & 16 deletions
This file was deleted.

examples/demo_pods/src/components/LoadingOverlay.tsx

Lines changed: 0 additions & 15 deletions
This file was deleted.

examples/demo_pods/src/components/LogView.css

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)