Kotlingradle实现中出现重复类错误

vhmi4jdf  于 2023-01-31  发布在  Kotlin
关注(0)|答案(1)|浏览(193)

我收到重复类错误作为gradle实现应用的build.gradle文件。但我不知道哪个实现实际上是重复的。我该如何解决这个问题?是否有更好的方法像使用bom来处理依赖项?

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'

}

android {
    namespace 'com.example.bettehomes'
    compileSdk 33

    defaultConfig {
        applicationId "com.example.bettehomes"
        minSdk 25
        targetSdk 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_version

            }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

dependencies {

        // Import the Compose BOM
    implementation 'com.google.android.gms:play-services-maps:18.1.0'
    implementation 'androidx.core:core-ktx:1.9.0'
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
    implementation 'androidx.activity:activity-compose:1.7.0-alpha04'
    implementation "androidx.compose.ui:ui-tooling:1.3.3"
    implementation "androidx.compose.ui:ui-tooling-preview:1.3.3"
    implementation 'androidx.compose.material3:material3:1.1.0-alpha04'
    // Android Studio Preview Support

    debugImplementation "androidx.compose.ui:ui-tooling:1.3.3"
    //testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.4.0-alpha05"
    debugImplementation "androidx.compose.ui:ui-test-manifest:1.3.3"
}
vtwuwzda

vtwuwzda1#

我今天遇到了这个问题,并使用gradle dependencies来计算dependency tree
我发现一个库使用了最新版本的appcompat,它使用了Kotlin1.8.0,这个版本有this issue
在我的例子中,修复方法是手动添加kotlinVersion

buildscript {
    ext {
        buildToolsVersion = "32.0.0"
        minSdkVersion = 21
        compileSdkVersion = 33
        targetSdkVersion = 32
        androidXBrowser = "1.4.0"
        
        kotlinVersion = "1.8.0"
    }
...
}

有关详细信息,请查看此问题:https://github.com/proyecto26/react-native-inappbrowser/issues/398

相关问题