Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle DSL Method not found: packagingOptions ()

I get an error when I sync the project about packagingOptions() not being found. error 51,0 My Gradle file looks like this:

apply plugin: 'com.android.application'


repositories {
    mavenCentral()
}

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile 'com.squareup.picasso:picasso:2.4.0'
    compile 'org.apache.httpcomponents:httpcore:4.3'
    compile 'org.apache.httpcomponents:httpmime:4.3.1'
    compile 'org.apache.httpcomponents:httpclient:4.3.5'
    compile 'org.apache.james:apache-mime4j:0.5'
    compile "com.android.support:appcompat-v7:21.0.+"
    compile project(':slidingLayer')
}

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.1"

    defaultConfig {
        applicationId "com.---.---"
        minSdkVersion 16
        targetSdkVersion 21
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_5
            targetCompatibility JavaVersion.VERSION_1_5
        }
    }


    dependencies {
        compile 'com.google.android.gms:play-services:6.1.71'
        compile files('src/main/libs/gson-2.2.4.jar')
    }

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

}

packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'
}

What am I missing? I have the packingOptions() in the same position in other projects. I just upgraded to Android Studio 1.0.

My gradle wrapper file is:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
like image 412
TheLettuceMaster Avatar asked Dec 11 '14 17:12

TheLettuceMaster


1 Answers

Either move packagingOptions into the android closure, or use android.packagingOptions where you have it, and see if that helps.

like image 139
CommonsWare Avatar answered Nov 19 '22 08:11

CommonsWare