Skip to content

Commit def8983

Browse files
committed
Refactor: Migrate to AGP 9.0 project structure
Migrate composeApp and data modules from the legacy android plugins to `com.android.kotlin.multiplatform.library`, and extract the Android application entry-point into a dedicated androidApp module.
1 parent 2eb37d9 commit def8983

33 files changed

Lines changed: 219 additions & 163 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Setup Gradle
1818
uses: gradle/actions/setup-gradle@v4.0.0
1919
- name: Build Android App
20-
run: ./gradlew composeApp:assembleDebug
20+
run: ./gradlew androidApp:assembleDebug
2121
- name: Run JVM Tests
2222
run: ./gradlew domain:jvmTest
2323
ios:

androidApp/build.gradle.kts

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/*
2+
* Abysner - Dive planner
3+
* Copyright (C) 2024 Neotech
4+
*
5+
* Abysner is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Affero General Public License version 3,
7+
* as published by the Free Software Foundation.
8+
*
9+
* You should have received a copy of the GNU Affero General Public License
10+
* along with this program. If not, see https://www.gnu.org/licenses/.
11+
*/
12+
13+
import java.util.Properties
14+
15+
val abysnerVersion: String by project.properties
16+
val abysnerBuildNumber: String by project.properties
17+
18+
plugins {
19+
alias(libs.plugins.androidApplication)
20+
alias(libs.plugins.compose.compiler)
21+
}
22+
23+
android {
24+
namespace = "nl.neotech.app.abysner"
25+
compileSdk = libs.versions.android.compileSdk.get().toInt()
26+
27+
28+
defaultConfig {
29+
applicationId = "nl.neotech.app.abysner"
30+
minSdk = libs.versions.android.minSdk.get().toInt()
31+
targetSdk = libs.versions.android.targetSdk.get().toInt()
32+
versionCode = abysnerBuildNumber.toInt()
33+
versionName = abysnerVersion
34+
}
35+
packaging {
36+
resources {
37+
excludes += "/META-INF/{AL2.0,LGPL2.1}"
38+
}
39+
}
40+
41+
val keystorePropertiesFile = rootProject.file("keystore.properties")
42+
val keystoreProperties = Properties()
43+
try {
44+
keystoreProperties.load(keystorePropertiesFile.inputStream())
45+
} catch (_: Exception) {
46+
logger.warn("w: Unable to load keystore.properties file!")
47+
}
48+
49+
signingConfigs {
50+
create("release") {
51+
keyAlias = keystoreProperties.getProperty("keyAlias")
52+
keyPassword = keystoreProperties.getProperty("keyPassword")
53+
keystoreProperties.getProperty("storeFile")?.let {
54+
storeFile = rootProject.file(it)
55+
}
56+
storePassword = keystoreProperties.getProperty("storePassword")
57+
storeType = keystoreProperties.getProperty("storeType") ?: "JKS"
58+
}
59+
}
60+
61+
buildTypes {
62+
getByName("debug") {
63+
applicationIdSuffix = ".debug"
64+
}
65+
getByName("release") {
66+
isMinifyEnabled = true
67+
proguardFiles(
68+
getDefaultProguardFile("proguard-android-optimize.txt"),
69+
"proguard-rules.pro"
70+
)
71+
signingConfig = signingConfigs.getByName("release")
72+
}
73+
create("development") {
74+
applicationIdSuffix = ".development"
75+
initWith(getByName("debug"))
76+
matchingFallbacks += listOf("release")
77+
isMinifyEnabled = true
78+
isDebuggable = false
79+
proguardFiles(
80+
getDefaultProguardFile("proguard-android-optimize.txt"),
81+
"proguard-rules.pro"
82+
)
83+
}
84+
}
85+
86+
compileOptions {
87+
sourceCompatibility = JavaVersion.VERSION_11
88+
targetCompatibility = JavaVersion.VERSION_11
89+
}
90+
buildFeatures {
91+
compose = true
92+
}
93+
}
94+
95+
96+
dependencies {
97+
implementation(project(":composeApp"))
98+
implementation(libs.androidx.activity.compose)
99+
100+
debugImplementation(libs.androidx.ui.tooling)
101+
}
102+
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<application
5+
android:allowBackup="true"
6+
android:icon="@mipmap/ic_launcher"
7+
android:label="@string/app_name"
8+
android:supportsRtl="true"
9+
android:name="org.neotech.app.abysner.AbysnerApplication"
10+
android:theme="@style/Theme.Abysner">
11+
<activity
12+
android:exported="true"
13+
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|mnc|colorMode|density|fontScale|fontWeightAdjustment|keyboard|layoutDirection|locale|mcc|navigation|smallestScreenSize|touchscreen|uiMode"
14+
android:name="org.neotech.app.abysner.MainActivity">
15+
<intent-filter>
16+
<action android:name="android.intent.action.MAIN" />
17+
18+
<category android:name="android.intent.category.LAUNCHER" />
19+
</intent-filter>
20+
</activity>
21+
</application>
22+
23+
</manifest>

composeApp/src/androidMain/kotlin/org/neotech/app/abysner/AbysnerApplication.kt renamed to androidApp/src/main/kotlin/org/neotech/app/abysner/AbysnerApplication.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@
1212

1313
package org.neotech.app.abysner
1414

15-
import android.app.Activity
1615
import android.app.Application
1716
import org.neotech.app.abysner.di.AppComponent
1817
import org.neotech.app.abysner.di.PlatformComponentImpl
1918
import org.neotech.app.abysner.di.create
20-
import java.lang.ref.WeakReference
2119

2220
class AbysnerApplication: Application() {
2321

@@ -32,6 +30,3 @@ class AbysnerApplication: Application() {
3230
fun appComponent(): AppComponent = appComponent
3331
}
3432

35-
// This is required for closeApp, but maybe a interface/implementation navigation class would be better
36-
// where the current activity is just injected, and the implementation is platform specific?
37-
internal var currentActivity: WeakReference<Activity> = WeakReference(null)

composeApp/src/androidMain/kotlin/org/neotech/app/abysner/MainActivity.kt renamed to androidApp/src/main/kotlin/org/neotech/app/abysner/MainActivity.kt

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)