How to solve android java.util.zip.ZipException error for google gms

Android Nov 5, 2016

Hello everybody, I have some problem to run my application in my phone and generate APK file but don’t have problem gradle build, why?

I have this error and search google to solve this, but unfortunately solution cannot solve my problem.

android java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzahn.class

I found solve my problem in Stack Overflow which so lucky from me

My problem from add some library in dependency with google play because my application use google map and authenticate with google sign-in then I comment out for similar and call 1 for all google play service to solve my problem successfully.

compile 'com.google.android.gms:play-services:9.8.0'
//compile 'com.google.android.gms:play-services-basement:9.8.0'
//compile 'com.google.android.gms:play-services-maps:9.8.0'
//compile 'com.google.android.gms:play-services-auth:9.8.0'

before that I have problem with multidex, add this in gradle

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.0"

    defaultConfig {
        ...
        minSdkVersion 14
        targetSdkVersion 21
        ...

        // Enabling multidex support.
        multiDexEnabled true
    }
    ...
}

dependencies {
  compile 'com.android.support:multidex:1.0.0'
}

and add the MultiDexApplication class from the multidex support library to the application element in manifest file.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.multidex.myapplication">
    <application
        ...
        android:name="android.support.multidex.MultiDexApplication">
        ...
    </application>
</manifest>

Tags

Minseo Chayabanjonglerd

I am a full-time Android Developer and part-time contributor with developer community and web3 world, who believe people have hard skills and soft skills to up-skill to da moon.