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

Android Studio(Java)添加FirebaseUI数据库依赖遇zip头部错误求助

Gradle缓存损坏导致的依赖读取错误解决方法

在Java版Android Studio项目中添加依赖implementation 'com.firebaseui:firebase-ui-database:8.0.1'后,出现以下错误:

error reading C:\Users\sourov ahmed.gradle\caches\modules-2\files-2.1\io.reactivex.rxjava3\rxjava\3.0.2\e652ec63717b1a92509abc8dc884fca0da3a974c\rxjava-3.0.2.jar; zip END header not found

项目的Gradle配置代码如下:

plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}

android {
compileSdk 32

    defaultConfig {
        applicationId "com.example.andromart"
        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
    }
    buildFeatures {
        viewBinding true
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.4.2'
    implementation 'com.google.android.material:material:1.6.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'com.google.firebase:firebase-database:20.0.5'
    implementation 'io.github.pilgr:paperdb:2.7.2'
    implementation 'de.hdodenhof:circleimageview:3.1.0'
    implementation 'com.google.firebase:firebase-storage:20.0.1'
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
    implementation 'androidx.navigation:navigation-fragment:2.5.1'
    implementation 'androidx.navigation:navigation-ui:2.5.1'
    implementation 'com.firebaseui:firebase-ui-database:8.0.1'

    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

解决步骤

  • 清理单个损坏的缓存文件
    错误提示明确指向rxjava-3.0.2.jar文件损坏,直接删除该文件所在的缓存目录:
    路径:C:\Users\sourov ahmed\.gradle\caches\modules-2\files-2.1\io.reactivex.rxjava3\rxjava\3.0.2
    删除后回到Android Studio,点击File → Sync Project with Gradle Files,Gradle会自动重新下载完整的依赖包。

  • 全局清理Gradle缓存(可选)
    如果删除单个文件后仍有类似错误,可执行全局缓存清理:

    1. 点击Android Studio菜单栏的File → Invalidate Caches...
    2. 勾选Invalidate and Restart选项,确认后等待IDE重启并自动重新构建项目。
  • 验证依赖版本兼容性
    当前使用的firebase-database:20.0.5和firebase-ui-database:8.0.1版本是兼容的(FirebaseUI 8.x对应Firebase BOM 29.x版本范围),如果后续仍有问题,可以尝试升级到官方推荐的最新兼容版本。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.22 19:39:28