AGP 9 androidApp + KMP :app split (toward Compose Multiplatform) - #108
AGP 9 androidApp + KMP :app split (toward Compose Multiplatform)#108markst wants to merge 9 commits into
Conversation
b671ef3 to
2b2efb3
Compare
Co-authored-by: markst <274318+markst@users.noreply.github.com>
Co-authored-by: markst <274318+markst@users.noreply.github.com>
The AGP Kotlin Multiplatform Android library plugin does not generate BuildConfig, so version/package metadata is initialized from the Application context instead.
Use com.android.kotlin.multiplatform.library with androidMain resources, keep existing Kotlin under src/main/kotlin via addStaticSourceDirectory, and relocate instrumented tests to androidDeviceTest.
Move Application, Activities, Manifest, and packaging into a thin com.android.application module so :app can remain the KMP library under AGP 9.
Point CI and README at androidApp:assembleDebug and record the AGP 9 module split in the migration checklist.
Wire androidMain to src/main/kotlin so Room generates _Impl, apply the Koin compiler plugin where module<T>() is called, and replace app-only generateLocaleConfig with a static locales_config. Co-authored-by: Cursor <cursoragent@cursor.com>
2b2efb3 to
bed179c
Compare
:app is now a KMP library under AGP 9, so assembleDebug lives on the thin application module. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
automatic locale config generation only works on the application module, and after the AGP 9 split the pieces were split across modules
…tivity. Use runtime FLAG_DEBUGGABLE via AppInfo and let CrashActivity own the stack-trace extra key so the library stays BuildConfig-free. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
not sure if you'd rather a better place for this?
|
I appreciate the effort but we need to slow down a bit and migrate chunk by chunk. This is a huge change in a single PR. |
Yeah was going to consult you and ask, I did start with a draft to get your input. Change may seem more significant than it is. I had started with just the 'shared' scaffold: 786f493. However decided maybe it was worthwhile converting the 'app' subproject to kmp and creating the agp 9 androidApp module. https://kotlinlang.org/docs/multiplatform/multiplatform-project-agp-9-migration.html |
|
I can break the PR into smaller chunks and start with just the androidApp module? |
Sorry, I couldn't reply in time. |
No don't worry! I agree it's a big PR. I'll take a look at making a smaller change |
There are lot of things we need to take care of.
That's why we need to migrate in a small step, replacing code that is strongly tied to Android and Java. |
|
Migrating from Jsoup to another library alone is huge and tedious work. I don't think there is any other HTML parsing library that is mature and easy-to-use than Jsoup. |
|
I would like to address these concerns first, before we even begin to migrate. |
|
Ksoup looks promising. |
|
I opened a new PR which simply creates the AGP 9 androidApp module: #109 I had started putting together a plan in this PR which outlines the steps for migrating. |
Summary
Structural change for #105: split into a thin Android application module and a Kotlin Multiplatform library so the tree aligns with AGP 9 (KMP cannot live in the same module as
com.android.application).Android remains the only shipping target;
commonMainis intentionally still empty of product code. This is the AGP 9 module split foundation for incremental KMP / Compose Multiplatform work, not a finished multiplatform migration.Rebased onto current
main.androidApp:assembleDebug/ cold start and GitHub Actions debug build are green.Module shape
:androidAppcom.android.application:appkotlin.multiplatform+com.android.kotlin.multiplatform.libraryandroidMaintoday) +jvm()for later portable peelsThe stub
:sharedscaffold is folded into:appso there is a single KMP library.Source layout
app/src/main/kotlinand register it on androidMain viakotlin.srcDir("src/main/kotlin")(avoids a mass rename; required so KSP/Room sees sources).app/src/androidMain/res(androidResources { enable = true }).commonMainat the whole Kotlin tree — peel packages intocommonMainincrementally (seedocs/kmp-migration-plan.md).Supporting changes
BuildConfigwith runtimeAppInfo.packageNameinto share / quick-search toggles (correct withapplicationIdSuffix).project.dependencies.platform(...)for Compose BOM;getByName("androidDeviceTest")for device-test deps.io.insert-koin.compiler.pluginon:androidApp(call site ofmodule<ViewModelModule>()).kspAndroidwithandroidMainsources soTorrentSearchDatabase_Implis generated.@xml/locales_config+ Manifestandroid:localeConfig(app-onlygenerateLocaleConfigcannot see library locales).androidApp:assembleDebug.Test plan
./gradlew androidApp:assembleDebug/assembleReleaseandroidApp:assembleDebug+ artifact path)SavedStateHandle(search / browse / details / Torznab edit / bookmarks filter)AppInfo)locales_config)Notes / non-goals
:sharedvs:app) or source-set convention feedback.