简体   繁体   中英

Android studio error: java.util.zip.ZipException: zip file is empty

When I am trying to build the application I getting error as

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. com.android.builder.dexing.DexArchiveMergerException: java.util.zip.ZipException: zip file is empty

I went and cleared the JDK. i reinstalled it again but still, I am getting the error. Any have any idea about it? Thanks in advance

    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'
}

Ok I finally solved the problem i just upgraded to Android Studio 3.1 Canary 6 i came across in some thread that this problem is specific to the Android Studio 3.0.1 of intellij platform (i will try to post the thread link later!) but i can not conclude the solution because even i just tried in other thread but i did not got answer yet. And still i am trying to find answer for this thread but for now the current fix is to upgrade the android version.

If you encountered this problem while minifyEnabled true in release you should add this line to your ProGuard-rules.pro file:

-keepparameternames

Hope this helps :)

Hope this helps:

multiDexEnabled true

Clean Project.
Rebuild Project

It's a late answer but it may possibly help someone. I've had similar issue today after upgrading Android Studio to the next version and compilation failed with the reason java.util.zip.ZipException: zip file is empty. It drove me crazy for the whole day and eventually deleting gradle cashes helped to solve it.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM