【问题标题】:Android studio error: java.util.zip.ZipException: zip file is emptyAndroid Studio 错误:java.util.zip.ZipException:zip 文件为空
【发布时间】:2018-01-05 06:42:45
【问题描述】:

当我尝试构建应用程序时,我收到错误

错误:任务 ':app:transformDexArchiveWithExternalLibsDexMergerForDebug' 执行失败。 com.android.builder.dexing.DexArchiveMergerException: java.util.zip.ZipException: zip 文件为空

我去清除了 JDK。我再次重新安装了它,但仍然出现错误。有人对此有任何想法吗? 提前致谢

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.vicky.sample"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

【问题讨论】:

  • 在这里添加你的 build.gradle 。
  • 好的,请稍等,我会添加
  • Unable to merge dex的可能重复
  • 不要只说是重复的仔细看问题
  • 我已经尝试了那些不起作用的解决方案,我还没有在我的项目中包含 GMS 服务

标签: android gradle android-gradle-plugin zip


【解决方案1】:

好的,我终于解决了我刚刚升级到 Android Studio 3.1 Canary 6 的问题,我在一些线程中遇到这个问题是 intellij 平台的 Android Studio 3.0.1 特有的(我稍后会尝试发布线程链接! )但我无法得出解决方案,因为即使我只是在其他线程中尝试过,但我还没有得到答案。我仍然试图为这个线程找到答案,但目前当前的修复是升级 android 版本。

【讨论】:

    【解决方案2】:

    如果你在发布时遇到这个问题 minifyEnabled true 你应该在你的 ProGuard-rules.pro 文件中添加这一行:

    -keepparameternames
    

    希望这会有所帮助:)

    【讨论】:

      【解决方案3】:

      希望这会有所帮助:

      multiDexEnabled true
      
      Clean Project.
      Rebuild Project
      

      【讨论】:

      • 让我知道你的 gradle 版本?
      • 类路径'com.android.tools.build:gradle:3.0.1'
      【解决方案4】:

      这是一个迟到的答案,但它可能会对某人有所帮助。在将 Android Studio 升级到下一个版本后,我今天遇到了类似的问题,编译失败,原因是 java.util.zip.ZipException: zip file is empty。它让我一整天都发疯了,最终删除 gradle cashes 帮助解决了这个问题。

      C:\Users\{user}\.gradle\caches

      【讨论】:

        猜你喜欢
        • 2014-09-13
        • 2021-03-25
        • 2016-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-11-15
        • 2018-06-16
        相关资源
        最近更新 更多