androidkotlingradleandroid-jetpack-compose

Android Compose: Type is defined multiple times


and thanks in advance for any help.

I'm new to Android development, so apologies if my question is stupid or duplicate.

I'm using jetpack compose on Android Studio 4.2.0-alpha12 and Gradle version 6.6.1. I'm getting the error when I build the app

Type com.example.athis.model.course.Coordinate-$$ExternalSynthetic1 is defined multiple times: /Users/noahtatko/AndroidStudioProjects/golf_score_android/app/build/intermediates/project_dex_archive/debug/out/com/example/athis/model/course/Coordinate.dex, /Users/noahtatko/AndroidStudioProjects/golf_score_android/app/build/intermediates/project_dex_archive/debug/out/com/example/athis/model/course/Hole.dex

The kotlin files (not the .dex files) are as follows:

// Hole.kt
package com.example.athis.model.course

import androidx.compose.runtime.Immutable

@Immutable
data class Hole(
    val id: Long,
    val hole: Long,
    val yards: Long,
    val handicap: Int,
    val par: Int,
    val coordinates: Coordinate
)
// Coordinate.kt
package com.example.athis.model.course

import androidx.compose.runtime.Immutable

@Immutable
data class Coordinate(
    val id: Long,
    val lat: Double,
    val long: Double
)

I've tried switching my gradle version, since that seems to be the normal fix, but because I'm using compose, I'm limited to releases after 6.6.1, none of which have helped.

One odd thing that may factor in: even though I'm on a Mac, I have a gradlew.bat file, and ./gradlew build does not work. Is there a way to regenerate these? I've tried deleting them, but then the app fails to run at all, not just build failures.


Solution

  • Turns out, the main issue was with the version of compose I was using 1.0.0-alpha3. Jumping to 1.0.0-alpha4 fixed everything.