0

I am using YouTubeAndroidPlayerApi in my project to play the youtube video through the Video ID. Everything works fine but except the issue that am facing while after enabling the proguard minifyEnabled true in my build.gradle. Please find my build.gradle configuration that I am using for proguard and error in the logcat as follows for your reference.

build.gradle

apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        consumerProguardFiles 'proguard-rules.txt'

    }


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

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.google.android.gms:play-services-gcm:8.3.0'
    compile files('lib/YouTubeAndroidPlayerApi.jar')

}

Logcat Error:

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/youtube/player/YouTubePlayerView.class

Note: The above error is occuring only when i enable proguard from minifyEnabled false to minifyEnabled true

What I tried:

I tried adding -keeppackagenames com.google.android.youtube.** { *; } in my proguard-rules.pro but none of the solution worked for me. Please help. Any kind of tips and suggestions would be very helpful to me. Thanks in advance.

Chandru
  • 5,954
  • 11
  • 45
  • 85
  • You will need to try to determine where the duplicates are coming from. I'd start by cleaning the project, in case the issue is tied to some leftover junk from earlier builds. Personally, I have never used `YouTubePlayerView` or any YouTube-related classes, so I have no specific advice for that library. – CommonsWare Mar 09 '16 at 11:59
  • @CommonsWare Thanks for your reply. But i dont think so it is because of duplicate junk issue. If it so, it shouldn't work on the case if i change minifyEnabled to false again. – Chandru Mar 09 '16 at 12:02
  • @Chandru - having a similar issue, did you find out the magic proguard command? – Gleno Dec 22 '20 at 19:36

0 Answers0