Skip to content

AGP 9 androidApp + KMP :app split (toward Compose Multiplatform) - #108

Closed
markst wants to merge 9 commits into
prajwalch:mainfrom
markst:propose/agp9-androidapp-kmp-split
Closed

AGP 9 androidApp + KMP :app split (toward Compose Multiplatform)#108
markst wants to merge 9 commits into
prajwalch:mainfrom
markst:propose/agp9-androidapp-kmp-split

Conversation

@markst

@markst markst commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

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; commonMain is 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

Module Plugin Role
:androidApp com.android.application Manifest, Application, Activities, packaging / F-Droid flags
:app kotlin.multiplatform + com.android.kotlin.multiplatform.library Existing UI / domain / data (compiled as androidMain today) + jvm() for later portable peels

The stub :shared scaffold is folded into :app so there is a single KMP library.

Source layout

  • Keep existing Kotlin under app/src/main/kotlin and register it on androidMain via kotlin.srcDir("src/main/kotlin") (avoids a mass rename; required so KSP/Room sees sources).
  • Android resources live in app/src/androidMain/res (androidResources { enable = true }).
  • Do not point commonMain at the whole Kotlin tree — peel packages into commonMain incrementally (see docs/kmp-migration-plan.md).

Supporting changes

  • Replace library BuildConfig with runtime AppInfo.
  • Pass runtime packageName into share / quick-search toggles (correct with applicationIdSuffix).
  • KMP DSL fixes: project.dependencies.platform(...) for Compose BOM; getByName("androidDeviceTest") for device-test deps.
  • Apply io.insert-koin.compiler.plugin on :androidApp (call site of module<ViewModelModule>()).
  • Room via kspAndroid with androidMain sources so TorrentSearchDatabase_Impl is generated.
  • Static @xml/locales_config + Manifest android:localeConfig (app-only generateLocaleConfig cannot see library locales).
  • README + CI point at androidApp:assembleDebug.

Test plan

  • ./gradlew androidApp:assembleDebug / assembleRelease
  • Cold start on emulator (MainActivity; Koin + Room graph)
  • GitHub Actions debug build (androidApp:assembleDebug + artifact path)
  • Coil images
  • Nav destinations that use SavedStateHandle (search / browse / details / Torznab edit / bookmarks filter)
  • Magnet open / share / process-text aliases (including debug package suffix)
  • Settings version row + log export (via AppInfo)
  • Per-app language picker (static locales_config)

Notes / non-goals

  • Not Compose Multiplatform UI yet.
  • Not iOS / Desktop shipping.
  • Networking (OkHttp/DoH), Cloudflare WebView cookies, and Jsoup scrapers stay Android/JVM for now.
  • Open to renaming (:shared vs :app) or source-set convention feedback.
image

@markst
markst force-pushed the propose/agp9-androidapp-kmp-split branch from b671ef3 to 2b2efb3 Compare August 12, 2026 04:32
Copilot AI and others added 7 commits August 13, 2026 12:54
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>
@markst
markst force-pushed the propose/agp9-androidapp-kmp-split branch from 2b2efb3 to bed179c Compare August 13, 2026 03:12
@markst markst changed the title RFC: AGP 9 androidApp + KMP :app split (toward Compose Multiplatform) RFC: AGP 9 androidApp + KMP :app split (build-verified) Aug 13, 2026
:app is now a KMP library under AGP 9, so assembleDebug lives on the thin application module.

Co-authored-by: Cursor <cursoragent@cursor.com>
@markst
markst marked this pull request as ready for review August 13, 2026 03:32
@markst markst changed the title RFC: AGP 9 androidApp + KMP :app split (build-verified) AGP 9 androidApp + KMP :app split (toward Compose Multiplatform) Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if you'd rather a better place for this?

@prajwalch

Copy link
Copy Markdown
Owner

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.

@markst

markst commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

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

@markst

markst commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

I can break the PR into smaller chunks and start with just the androidApp module?

@markst markst closed this Aug 13, 2026
@prajwalch

Copy link
Copy Markdown
Owner

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.

Sorry, I couldn't reply in time.

@markst

markst commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

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

@prajwalch

prajwalch commented Aug 13, 2026

Copy link
Copy Markdown
Owner

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.

  • Jsoup is a Java library which is one of the important dependencies for our project. Will it work on multiplatform?
  • TorrentDateParser uses java.time.
  • Markdown rendering uses Android-only library.
  • WebView is used to unlock Cloudflare-protected providers. How will we achieve that in multiplatform?
  • There are other codes that is strongly tied to Android.

That's why we need to migrate in a small step, replacing code that is strongly tied to Android and Java.

@prajwalch

Copy link
Copy Markdown
Owner

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.

@prajwalch

Copy link
Copy Markdown
Owner

I would like to address these concerns first, before we even begin to migrate.

@prajwalch

Copy link
Copy Markdown
Owner

Ksoup looks promising.

@markst

markst commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

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.
However I'm happy to start looking into migrating Jsoup as a starting point before adding multiplatform plugin.

@markst

markst commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Ksoup looks promising.

Ksoup seems like a drop in replacement for Jsoup, so it's a easy migration:
#110

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants