LoginSignup
0
0

More than 1 year has passed since last update.

【Android】ビルドバリアントに合わせて同じコンポーザブルを作ったら、Conflicting overloads...というエラーが出たときのまとめ

Posted at

エラーが発生した時の状況

build.gradleにあたらしいproductTypeproductFlavorsを追加した。

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.debug
    }
    debug {
        applicationIdSuffix ".debug"
        debuggable true
    }
}

flavorDimensions "plan"

productFlavors {
    paid {
        dimension "plan"
    }
    free {
        dimension "plan"
    }
}

freeReleasepaidReleaseに同じ名前空間のファイルを作成した。

- freeRelease
    - java
        - com.takagimeow.example
            - feature
                - home
                    - HomeScreen.kt
- paidRelease
    - java
        - com.takagimeow.example
            - feature
                - home
                    - HomeScreen.kt
- main
    - java
        - com.takagimeow.example
            - feature
                - home
                    - HomeScreen.kt

このとき、エディター上に、Conflicting overloads...というエラーが表示された。

解決した手順

ディレクトリ名をfreepaidに変更した。

開発環境では、AndroidStudioが自動で署名してくれる、debugビルドタイプを優先的に使用する。そのため、releasedebugの両方に対応するためproductFlavorsの値に合わせたディレクトリ名にする。

- free
    - java
        - com.takagimeow.example
            - feature
                - home
                    - HomeScreen.kt
- paid
    - java
        - com.takagimeow.example
            - feature
                - home
                    - HomeScreen.kt
- main
    - java
        - com.takagimeow.example
            - feature
                - home
                    - HomeScreen.kt

そして、mainに存在する同じコンポーザブルのファイルを削除する。この時、コメントアウトだけでごまかさないようにする。

- free
    - java
        - com.takagimeow.example
            - feature
                - home
                    - HomeScreen.kt
- paid
    - java
        - com.takagimeow.example
            - feature
                - home
                    - HomeScreen.kt
- main
    - java
        - com.takagimeow.example
            - feature
                - home

それでも解決しない場合は、.ideaディレクトリを削除するなどをしてみる。

それ以外の方法については、こちらの記事を参照してみてほしい。

0
0
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
0
0