エラーと解決方法一覧
The binary version of its metadata is 2.0.0, expected version is 1.8.0.
→ org.jetbrains.kotlin.androidを2.00に変更
// build.gradle(:root)
plugins {
id 'org.jetbrains.kotlin.android' version '2.0.0' apply false
}
Starting in Kotlin 2.0, the Compose Compiler Gradle plugin is required
→ ルートと各モジュールに「org.jetbrains.kotlin.plugin.compose」を加える
// build.gradle(:root)
plugins {
id("org.jetbrains.kotlin.plugin.compose") version "2.0.0" apply false
}
// build.gradle(各モジュール)
plugins {
id("org.jetbrains.kotlin.plugin.compose")
}
Execution failed for task ‘:app:kaptDebugKotlin’.
→ 公式に沿ってkaptをkspに変更する
注意:下記コード内に記載のとおりKotlinバージョンと合わせる必要があります。一覧はこちら。
// build.gradle(:root)
plugins {
// Kotlinバージョン
id("org.jetbrains.kotlin.plugin.compose") version "2.0.0" apply false
// 下記バージョン「a.b.c-x.y.z」のa.b.cはKotlinバージョンと同じである必要があります
// Kotlinバージョンが「2.0.0」の場合
id("com.google.devtools.ksp") version "2.0.21-1.0.27" apply false
}
// build.gradle(各モジュール)
plugins {
// id("org.jetbrains.kotlin.kapt") <- 削除
// id 'kotlin-kapt' <- 削除
id("com.google.devtools.ksp")
}
dependencies {
// kaptをkspに変更
// 例
// kapt("androidx.room:room-compiler:2.5.0") <- 下のksp版に変更
ksp("androidx.room:room-compiler:2.5.0")
}
// kapt { <- 削除
// correctErrorTypes = true
// useBuildCache = true
// }
Expected @HiltAndroidApp to have a value. Did you forget to apply the Gradle Plugin?
→ 公式に沿ってHiltを導入もしくはバージョンアップ
// build.gradle(:root)
plugins {
...
id 'com.google.dagger.hilt.android' version '2.56.2' apply false
}
// build.gradle(各モジュール)
plugins {
id 'com.google.devtools.ksp'
id 'com.google.dagger.hilt.android'
}
android {
...
}
dependencies {
implementation "com.google.dagger:hilt-android:2.56.2"
ksp "com.google.dagger:hilt-compiler:2.56.2"
}
[ksp] InjectProcessingStep was unable to process ‘ファイル名’ because ‘クラス名’ could not be resolved.
→ protoのバージョンアップ
// build.gradle(各モジュール)
plugins {
id "com.google.protobuf" version "0.9.5"
}
dependencies {
implementation "androidx.datastore:datastore:1.1.7"
implementation "com.google.protobuf:protobuf-javalite:4.27.1"
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:4.27.1"
}
generateProtoTasks {
all().each { task ->
task.builtins {
java {
option 'lite'
}
}
}
}
}
Could not instantiate Worker
→ hilt系のアップデート
// build.gradle(各モジュール)
dependencies {
implementation 'androidx.hilt:hilt-navigation-compose:1.2.0'
implementation 'androidx.hilt:hilt-work:1.2.0'
ksp 'androidx.hilt:hilt-compiler:1.2.0'
}
lateinit property workerFactory has not been initialized
→ workerFactoryをAssistedInjectに変更
@HiltAndroidApp
class ArchitectureApplication : Application(), Configuration.Provider {
@EntryPoint
@InstallIn(SingletonComponent::class)
interface HiltWorkerFactoryEntryPoint {
fun workerFactory(): HiltWorkerFactory
}
private val workerFactory = EntryPoints.get(this, HiltWorkerFactoryEntryPoint::class.java).workerFactory()
override val workManagerConfiguration = Configuration.Builder()
.setWorkerFactory(workerFactory)
.build()
override fun onCreate() {
super.onCreate()
Notification.initialize(context = this)
}
}
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/compose/runtime/SnapshotFloatStateKt
→ compose:material3のアップデート
// build.gradle(各モジュール)
dependencies {
implementation 'androidx.compose.material3:material3:1.3.2'
}