You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio引入Eclipse Milo Client SDK构建失败求助

Android Studio集成Eclipse Milo Client SDK构建失败:META-INF/INDEX.LIST重复冲突解决

问题描述

在Android Studio项目中通过Gradle集成Maven中央仓库的org.eclipse.milo:sdk-client:0.6.11依赖时,mergeDebugJavaResource任务执行失败,报错原因是多个依赖包中存在重复的META-INF/INDEX.LIST文件。移除该Milo依赖后,项目可正常完成构建。

原项目Gradle配置如下:

plugins {
    id("com.android.application")
    id("org.jetbrains.kotlin.android")
}

android {
    namespace = "com.example.opcua"
    compileSdk = 33

    defaultConfig {
        applicationId = "com.example.opcua"
        minSdk = 26
        targetSdk = 33
        versionCode = 1
        versionName = "1.0"

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

    buildTypes {
        release {
            isMinifyEnabled = 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 = "1.4.3"
    }
    packaging {
        resources {
            excludes += "/META-INF/{AL2.0,LGPL2.1}"
        }
    }
}

dependencies {
    implementation("org.eclipse.milo:sdk-client:0.6.11") // 移除此行构建正常
    implementation("androidx.core:core-ktx:1.9.0")
    implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
    implementation("androidx.activity:activity-compose:1.7.0")
    implementation(platform("androidx.compose:compose-bom:2023.03.00"))
    implementation("androidx.compose.ui:ui")
    implementation("androidx.compose.ui:ui-graphics")
    implementation("androidx.compose.ui:ui-tooling-preview")
    implementation("androidx.compose.material3:material3")
    testImplementation("junit:junit:4.13.2")
    androidTestImplementation("androidx.test.ext:junit:1.1.5")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
    androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00"))
    androidTestImplementation("androidx.compose.ui:ui-test-junit4")
    debugImplementation("androidx.compose.ui:ui-tooling")
    debugImplementation("androidx.compose.ui:ui-test-manifest")
}

解决方法

修改Gradle的packaging配置,在资源排除规则中添加META-INF/INDEX.LIST,让Gradle打包时忽略重复的该文件:

更新后的packaging块代码:

packaging {
    resources {
        excludes += "/META-INF/{AL2.0,LGPL2.1,INDEX.LIST}"
    }
}

或者拆分写法更清晰:

packaging {
    resources {
        excludes += "/META-INF/AL2.0"
        excludes += "/META-INF/LGPL2.1"
        excludes += "/META-INF/INDEX.LIST"
    }
}

修改完成后重新执行构建,即可解决重复文件冲突导致的失败问题。

内容的提问来源于stack exchange,提问作者Роман Малиновський

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 21:42:33