Files
2nd/10_Wiki/Topic_Programming/Coding/Android_Modularization.md
T
Antigravity Agent 9148c358d0 docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를
Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류.

- 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로
  자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거,
  동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거.
- 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming,
  Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business,
  Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로,
  나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는
  title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백).
  원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지.
- 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서.
- 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는
  지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지.
- Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경.
- 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
2026-07-05 00:33:48 +09:00

4.7 KiB

id, title, category, status, source_trust_level, verification_status, created_at, updated_at, tags, tech_stack, applied_in, aliases
id title category status source_trust_level verification_status created_at updated_at tags tech_stack applied_in aliases
android-modularization Android Modularization — Feature / Core / App Coding draft B conceptual 2026-05-09 2026-05-09
android
gradle
modularization
vibe-coding
language applicable_to
Kotlin / Gradle
Android
feature module
core module
build time
dynamic feature

Android Modularization

한 모듈 앱은 빌드 시간과 응집도가 폭발한다. feature : core : data : app 4계층 분리 + 단방향 의존성 = 빠른 빌드 + 명확한 책임. 잘못된 의존성은 cyclical → gradle 폭사.

📖 핵심 개념

일반적 4계층:

  • app: Application class, AppNav. 모든 feature import.
  • feature:xxx: 한 feature 의 UI + ViewModel.
  • core:: 공통 (ui-kit, designsystem, network, database).
  • data:xxx: repository, remote, local.

규칙: 모든 의존성 위에서 아래로. feature 끼리는 직접 X (app 만 안다).

💻 코드 패턴

Project 구조

:app
:feature:home
:feature:profile
:feature:order
:core:ui (Compose theme, components)
:core:network (Retrofit, OkHttp)
:core:database (Room)
:core:common
:data:user (UserRepo)
:data:order (OrderRepo)

settings.gradle.kts

include(":app")
include(":feature:home", ":feature:profile", ":feature:order")
include(":core:ui", ":core:network", ":core:database", ":core:common")
include(":data:user", ":data:order")

feature module — build.gradle.kts

plugins {
    alias(libs.plugins.android.library)
    alias(libs.plugins.kotlin.android)
    alias(libs.plugins.hilt)
    alias(libs.plugins.ksp)
}

android {
    namespace = "com.example.feature.profile"
    compileSdk = 34
    defaultConfig { minSdk = 26 }
}

dependencies {
    implementation(project(":core:ui"))
    implementation(project(":core:common"))
    implementation(project(":data:user"))
    // feature 끼리 의존 X
    implementation(libs.compose.foundation)
    implementation(libs.hilt.android)
    ksp(libs.hilt.compiler)
}

Convention plugin — 중복 제거

// build-logic/src/main/kotlin/AndroidFeatureConventionPlugin.kt
class AndroidFeatureConventionPlugin : Plugin<Project> {
    override fun apply(target: Project) = with(target) {
        pluginManager.apply("com.android.library")
        pluginManager.apply("org.jetbrains.kotlin.android")
        pluginManager.apply("com.google.dagger.hilt.android")

        extensions.configure<LibraryExtension> {
            compileSdk = 34
            defaultConfig { minSdk = 26 }
            compileOptions { ... }
        }
        dependencies {
            "implementation"(project(":core:ui"))
            "implementation"(project(":core:common"))
        }
    }
}

// feature/profile/build.gradle.kts
plugins { id("android.feature") }

app — composition root

@HiltAndroidApp
class App : Application()

// AppNav.kt
@Composable
fun AppNav(nav: NavHostController) {
    NavHost(nav, startDestination = HomeRoute) {
        homeGraph(nav)        // feature:home extension
        profileGraph(nav)     // feature:profile extension
        orderGraph(nav)       // feature:order extension
    }
}

각 feature 가 NavGraphBuilder extension 을 export.

Build cache + parallel

# gradle.properties
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.configureondemand=true
android.enableJetifier=false
kotlin.incremental.useClasspathSnapshot=true

🤔 의사결정 기준

앱 크기 모듈화
<10 화면 단일 모듈 OK
10-30 feature 별 분리 시작
30+ 4계층 fully modular
팀 다수 명확 ownership boundary 로 모듈
Dynamic delivery feature module = on-demand download

안티패턴

  • feature ↔ feature 직접 의존: cyclical 가능. app 또는 navigation contract 통해서.
  • core 가 feature import: 역방향. core 는 가장 아래.
  • 거대 :common 에 모든 것: 어떤 변경도 모든 모듈 재빌드. 잘게 분리.
  • 모듈마다 다른 minSdk / compileSdk: 일관성 깨짐. convention plugin.
  • 각 모듈에 같은 dependency 중복 선언: convention plugin 으로.
  • 순환 의존 발견 늦음: gradle build 시 즉시 실패. 의존 그래프 시각화 (Gradle Dependency Insight).
  • feature module 이 직접 Application class 참조: app 의존성 역방향.

🤖 LLM 활용 힌트

  • 신규 Android = 4계층 modular 출발.
  • convention plugin 으로 boilerplate 제거.
  • feature 끼리는 NavGraphBuilder extension 으로만 통신.

🔗 관련 문서