Android Architecture Samples でみる JetpackCompose UI コンポーネントのネスト



表示されてるコンテンツまでにいくつかのコンポーネントを経由している。

👉 architecture-samples/app/src/main/java/com/example/android/architecture/blueprints/todoapp/TodoNavGraph.kt at 130f5dbebd0c7b5ba195cc08f25802ed9f0237e5 · android/architecture-samples

中心は、NavGraph として利用されている NavHost

ModalDrawer ごと切り替えてる。


Activity
  + NavHost
    + ModalDrawer
      + 【Screen】
        + Scaffold
          + SwipeRefresh
            + 【Content】    
    + ModalDrawer
      + 【Screen】
        + Scaffold
          + SwipeRefresh
            + 【Content】
    + ModalDrawer
      + 【Screen】
        + Scaffold
          + SwipeRefresh
            + 【Content】

きっと、使いやすい理にかなった入れ子関係なのだろう。


Activity
   ↓
NavHost
   ↓ 1:*
ModalDrawer
   ↓
【Screen】
   ↓
Scaffold
   ↓
SwipeRefresh
   ↓
【Content】

参考にしたいですね。

👉 android/architecture-samples: A collection of samples to discuss and showcase different architectural tools and patterns for Android apps.


【Kotlin】バージョンカタログ libs.versions.toml の記述だるくね? module 記述のほうが良くね?

なんか面倒なだけな気がしてきた。


hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" }
hilt-compiler = { group = "com.google.dagger", name = "hilt-compiler", version.ref = "hilt" }

group, name より、

module 記述で良くないか。


hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hilt" }
hilt-compiler = { module = "com.google.dagger:hilt-compiler", version.ref = "hilt" }

まあ、無駄に几帳面に書いてました。

こんなにスッキリ。

👉 Pokedex/gradle/libs.versions.toml at main · skydoves/Pokedex


【Android】Hilt + KSP で error.NonExistentClass を解決するヒント - Protobuf / SQLDelight / ViewBinding / AIDL

見かけましたよね。

以下に似たようなエラー。


e: [ksp] InjectProcessingStep was unable to process 'RemoteUnfoldTransitionReceiver(boolean,java.util.concurrent.Executor)' because 'error.NonExistentClass' could not be resolved.

Dependency trace:
    => element (CLASS): com.android.systemui.unfold.progress.RemoteUnfoldTransitionReceiver
    => type (ERROR superclass): error.NonExistentClass

If type 'error.NonExistentClass' is a generated type, check above for compilation errors that may have prevented the type from being generated. Otherwise, ensure that type 'error.NonExistentClass' is on your classpath.
e: [ksp] InjectProcessingStep was unable to process 'UnfoldTransitionProgressForwarder()' because 'error.NonExistentClass' could not be resolved.

Dependency trace:
    => element (CLASS): com.android.systemui.unfold.progress.UnfoldTransitionProgressForwarder
    => type (ERROR superclass): error.NonExistentClass

If type 'error.NonExistentClass' is a generated type, check above for compilation errors that may have prevented the type from being generated. Otherwise, ensure that type 'error.NonExistentClass' is on your classpath.
e: [ksp] ComponentProcessingStep was unable to process 'com.android.systemui.unfold.RemoteUnfoldSharedComponent' because 'error.NonExistentClass' could not be resolved.

Dependency trace:
    => element (CLASS): com.android.systemui.unfold.progress.RemoteUnfoldTransitionReceiver
    => type (ERROR superclass): error.NonExistentClass

If type 'error.NonExistentClass' is a generated type, check above for compilation errors that may have prevented the type from being generated. Otherwise, ensure that type 'error.NonExistentClass' is on your classpath.
e: Error occurred in KSP, check log for detail

私は、SDKバージョンアップ時に SQLDelight で出会いましたが以下で回避。


// bottom of app/build.gradle.kts

androidComponents {
  onVariants(selector().all()) { variant ->
    afterEvaluate {
      val capName = variant.name.capitalize()
      tasks.getByName<KotlinCompile>("ksp${capName}Kotlin") {
        setSource(tasks.getByName("generate${capName}DatabaseInterface").outputs)
      }
    }
  }
}

👉 [ksp] InjectProcessingStep was unable to process a class which extends Binder Stub because 'error.NonExistentClass' could not be resolved. · Issue #4158 · google/dagger

こんな「とりあえず回避」ってのよくありますが

対応コードが溜まっていくと後々意味不明になるので

なんか嫌ですけど、

仕方ないんですよね。

👉 SqlDelight inconsistency with KSP · Issue #5473 · sqldelight/sqldelight
👉 KSP Compilation Failure: Unresolved `error.NonExistentClass` during `MarketDaoImpl` and `LocalDatasourceModule` processing · Issue #2092 · google/ksp
👉 SQLDelight 2.0 Tasks · Issue #2694 · sqldelight/sqldelight