Gradle duplicate entry error: META-INF/MANIFEST.MF (Or how to delete a file from jar) : <p>I've cloned a github repository because I wanted to study the code, but when I tried to build it in Android Studio, I ran into some trouble.
After adding the google maven repository (as prompted by Android Studio) and updating both the Gradle Plugin Version and the Grade Version (to 3.5.2 and to 5.4.1, respectively), the build fails because of the following error:</p>

<blockquote>
  <p>Cause: duplicate entry: META-INF/MANIFEST.MF</p>
</blockquote>

<p>And this, to be more specific:</p>

<blockquote>
  <p>Caused by: java.util.zip.ZipException: duplicate entry: META-INF/MANIFEST.MF</p>
</blockquote>

<p>Here is my project level build.gradle file:</p>

<pre><code>
    buildscript {
        repositories {
            jcenter()
            google()
        }

        dependencies {
            classpath 'com.android.tools.build:gradle:3.5.2'

            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }

    allprojects {
        repositories {
            jcenter()

            maven {
                url 'https://maven.google.com'
            }

        }
    }

</code></pre>

<p>Here's my module build.gradle file (before trying anything):</p>

<pre><code>
    apply plugin: 'com.android.application'

    android {
        compileSdkVersion 22
        buildToolsVersion '28.0.3'

        defaultConfig {
            applicationId "com.thelittlenaruto.supportdesignexample"
            minSdkVersion 11
            targetSdkVersion 22
            versionCode 1
            versionName "1.0"
        }

        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:22.2.1')
        implementation ('com.android.support:design:22.2.1')
        implementation 'com.github.frankiesardo:linearlistview:1.0.1@aar'
    }

</code></pre>

<p>Here's what I've tried so far:</p>

<ul>
<li>Adding the following to the android section of my module build.gradle file:</li>
</ul>

<pre><code>
    sourceSets {
            main{
                java{
                    exclude '**/META-INF/MANIFEST'
                    exclude '**/META-INF/MANIFEST.MF'
                    exclude 'META-INF/MANIFEST'
                    exclude 'META-INF/MANIFEST.MF'
                    exclude '!META-INF/MANIFEST.MF'
                }
            }
        }

</code></pre>

<ul>
<li>Adding this:</li>
</ul>

<pre><code>
    sourceSets.main.res.filter.exclude 'META-INF/MANIFEST'
        sourceSets.main.res.filter.exclude 'META-INF/MANIFEST.MF'

</code></pre>

<ul>
<li>Also this:</li>
</ul>

<pre><code>
    packagingOptions {
            apply plugin: 'project-report'
            exclude '**/META-INF/MANIFEST'
            exclude '**/META-INF/MANIFEST.MF'
            exclude 'META-INF/MANIFEST'
            exclude 'META-INF/MANIFEST.MF'
            exclude '!META-INF/MANIFEST.MF'
        }

</code></pre>

<ul>
<li>And this:</li>
</ul>

<pre><code>
    packagingOptions {
            pickFirst '**/META-INF/MANIFEST'
            pickFirst '**/META-INF/MANIFEST.MF'
            pickFirst 'META-INF/MANIFEST'
            pickFirst 'META-INF/MANIFEST.MF'
            pickFirst '!META-INF/MANIFEST.MF'
        }

</code></pre>

<ul>
<li>This:</li>
</ul>

<pre><code>
    aaptOptions {
            ignoreAssetsPattern "!META-INF/MANIFEST.MF"
            ignoreAssetsPattern "META-INF/MANIFEST.MF"
        }

</code></pre>

<p>I think I've tried mostly everything in this question:
<a href="https://stackoverflow.com/questions/41899973/how-to-exclude-certain-files-from-android-studio-gradle-builds">How to exclude certain files from Android Studio gradle builds?</a></p>

<p>Nothing worked.</p>

<p>After searching for a solution, I think the problem is that I have duplicated dependencies. So I've tried the following:</p>

<pre><code>
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation ('com.android.support:appcompat-v7:22.2.1'){
            exclude module: 'support-v4'
        }
        implementation ('com.android.support:design:22.2.1')
        implementation 'com.github.frankiesardo:linearlistview:1.0.1@aar'
    }

</code></pre>

<p>And this:</p>

<pre><code>
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation ('com.android.support:design:22.2.1'){
            exclude module: 'support-v7'
        }
        implementation 'com.github.frankiesardo:linearlistview:1.0.1@aar'
    }

</code></pre>

<p>I still get the same error.</p>

<p>Could anyone please tell me what I'm doing wrong?
Thank you in anticipation. :)</p>
