Skip to content

Refactor: Separate Android App Module for AGP 9.0 Compatibility#34

Merged
l2hyunwoo merged 3 commits into
l2hyunwoo:mainfrom
angryPodo:refactor/agp-compatibility
Dec 29, 2025
Merged

Refactor: Separate Android App Module for AGP 9.0 Compatibility#34
l2hyunwoo merged 3 commits into
l2hyunwoo:mainfrom
angryPodo:refactor/agp-compatibility

Conversation

@angryPodo

@angryPodo angryPodo commented Dec 29, 2025

Copy link
Copy Markdown
Contributor

Overview

This PR addresses issue #31 by refactoring the sample module structure to comply with upcoming Android Gradle Plugin (AGP) 9.0 requirements.

Starting with AGP 9.0, applying com.android.application and kotlin("multiplatform") in the same module is deprecated. This PR separates the Android application entry point from the KMP shared code.

Structural Changes

Before

sample/
├── build.gradle.kts (Plugins: 'com.android.application' + 'kotlin-multiplatform')
├── src/
│   ├── commonMain/
│   ├── androidMain/ (Contains both App Manifest/Activity AND Shared Logic)
│   └── iosMain/

After

sample/
├── shared/ (New KMP Module)
│   ├── build.gradle.kts (Plugins: 'com.android.library' + 'kotlin-multiplatform')
│   └── src/ (Moved commonMain, iosMain, and shared androidMain logic)
│
└── android-app/ (New Android Application Module)
    ├── build.gradle.kts (Plugins: 'com.android.application' + 'kotlin-android')
    └── src/ (Contains AndroidManifest.xml, MainActivity, App Resources)

Related Issue

Resolves #31

- Move shared KMP code to `sample/shared`
- Move Android entry point to `sample/android-app`
- Update Gradle settings to include new modules
- Fix iOS project reference to point to shared module task
- Resolves #31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR successfully refactors the sample module structure to comply with Android Gradle Plugin (AGP) 9.0 requirements, which deprecates the use of com.android.application and kotlin("multiplatform") plugins in the same module. The refactoring separates the Android application entry point from the Kotlin Multiplatform shared code.

Key Changes:

  • Split the :sample module into :sample:shared (KMP library) and :sample:android-app (Android application)
  • Migrated shared Kotlin Multiplatform code (including commonMain, androidMain, and iosMain source sets) to the new :sample:shared module
  • Created a new Android-only :sample:android-app module that depends on :sample:shared and serves as the application entry point
  • Updated iOS project configuration to reference the new framework output path from :sample:shared

Reviewed changes

Copilot reviewed 4 out of 21 changed files in this pull request and generated no comments.

Show a summary per file
File Description
settings.gradle.kts Updated module includes from :sample to :sample:shared and :sample:android-app
sample/shared/build.gradle.kts Converted from android.application to android.kotlin.multiplatform.library plugin with appropriate KMP configuration
sample/android-app/build.gradle.kts New Android application module with kotlin-android plugin and dependency on :sample:shared
sample/android-app/src/main/AndroidManifest.xml Android app manifest with camera permissions and MainActivity declaration
sample/android-app/src/main/kotlin/.../MainActivity.kt Android app entry point that launches the shared SampleApp composable
sample/android-app/src/main/res/* Android app resources including theme and strings definitions
sample/shared/src/commonMain/kotlin/* Shared KMP source files moved from original sample module including SampleApp, CameraScreen, GalleryScreen, BarcodeScannerScreen, and related utilities
sample/shared/src/androidMain/kotlin/* Android-specific implementations of MediaLoader, MediaThumbnail, and BackHandler
sample/shared/src/iosMain/kotlin/* iOS-specific implementations including MainViewController, MediaLoader, MediaThumbnail, and BackHandler
iosApp/iosApp.xcodeproj/project.pbxproj Updated framework search paths and Gradle task references to point to :sample:shared instead of :sample

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@l2hyunwoo l2hyunwoo left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

LGTM 👍🏻 Thanks for your contribution.

@l2hyunwoo l2hyunwoo merged commit 9b2f7a9 into l2hyunwoo:main Dec 29, 2025
9 checks passed
@injae-kim

Copy link
Copy Markdown

Awesooome @angryPodo thank you!! ❤️

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.

'org.jetbrains.kotlin.multiplatform' plugin deprecated compatibility with Android Gradle plugin: 'com.android.application'

4 participants