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

Android项目集成Google BigQuery遇mergeDebugJavaResource构建错误

Android集成Google BigQuery Java库构建报错解决

问题背景

尝试在Java Android项目中集成Google BigQuery Java库,Gradle同步无异常,但构建项目时触发资源合并失败错误。已尝试清理项目、重置Gradle缓存,问题未解决。

当前环境:

  • Gradle版本:7.4
  • Android Studio版本:Dolphin | 2021.3.1 Patch 1

错误信息

* What went wrong:
Execution failed for task ':app:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
   > 4 files found with path 'arrow-git.properties' from inputs:
      - C:\\Users\\marta.echevarria\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.arrow\\arrow-vector\\10.0.0\\80827840cea658527dd06aef6567868bc4fa24a\\arrow-vector-10.0.0.jar
      - C:\\Users\\marta.echevarria\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.arrow\\arrow-format\\10.0.0\\c8e2d494a6f6ac39a3aa8961cf8a38c0a0e82dbb\\arrow-format-10.0.0.jar
      - C:\\Users\\marta.echevarria\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.arrow\\arrow-memory-core\\10.0.0\\79ab45e0a148b395cfb610767c7bcd08e90da623\\arrow-memory-core-10.0.0.jar
      - C:\\Users\\marta.echevarria\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.arrow\\arrow-memory-netty\\10.0.0\\faab301a8f950bfeefeef31447f426c2ea2d4c8c\\arrow-memory-netty-10.0.0.jar

当前Gradle配置

plugins {
    id 'com.android.application'
}

android {
    namespace 'com.example.myapplication'
    compileSdk 32

    defaultConfig {
        applicationId "com.example.myapplication"
        minSdk 21
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    packagingOptions {
        exclude 'META-INF/INDEX.LIST'
        exclude 'META-INF/DEPENDENCIES'
    }
}

configurations {
    cleanedAnnotations
    implementation.exclude group: 'com.google.auto.value', module: 'auto-value'
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.5.1'
    implementation 'com.google.android.material:material:1.7.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.4'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'

    implementation platform('com.google.cloud:libraries-bom:26.1.4')
    implementation 'com.google.cloud:google-cloud-bigquery'
}

解决方案

问题根源是多个Apache Arrow依赖包包含同名的arrow-git.properties文件,导致Java资源合并时冲突。修改packagingOptions配置即可解决,以下两种方案二选一:

方案1:保留第一个找到的文件

在android块的packagingOptions中添加规则:

packagingOptions {
    exclude 'META-INF/INDEX.LIST'
    exclude 'META-INF/DEPENDENCIES'
    pickFirst 'arrow-git.properties'
}

方案2:直接排除该文件

在android块的packagingOptions中添加规则:

packagingOptions {
    exclude 'META-INF/INDEX.LIST'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'arrow-git.properties'
}

修改后重新构建项目即可解决冲突问题。

内容的提问来源于stack exchange,提问作者Martis

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.09 04:51:12