LoginSignup
1
1

More than 3 years have passed since last update.

[Android]GsonからMoshiに移行しようとした時、ビルドができなくなった

Posted at

状況

GsonからMoshiに移行した時にビルド時にエラーが出てしまった。

Mohsiをプロジェクトに追加する

以下をgraldeに追加しMoshiを既存プロジェクトに入れる。

gradle.app
    def moshi_version = '1.5.0'
    implementation "com.squareup.moshi:moshi:$moshi_version"
    implementation "com.squareup.moshi:moshi-kotlin:$moshi_version"

ビルドすると、下記エラーが出た。

エラー内容

Duplicate class kotlin.reflect.KClasses found in modules jetified-kotlin-reflect-1.1.1.jar (org.jetbrains.kotlin:kotlin-reflect:1.1.1) and jetified-kotlin-stdlib-1.3.72.jar (org.jetbrains.kotlin:kotlin-stdlib:1.3.72)
Go to the documentation to learn how to Fix dependency resolution errors.

解決方法

gradleに一行追加したらビルドできた。

gradle.app
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1