2014-12-11 18 views
17

Tôi gặp lỗi khi đồng bộ hóa dự án về packagingOptions() không được tìm thấy. error 51,0 tập tin của tôi Gradle trông như thế này:Phương thức DSL Gradle không tìm thấy: packagingOptions()

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

tôi thiếu gì? Tôi có packingOptions() ở cùng vị trí trong các dự án khác. Tôi vừa nâng cấp lên Android Studio 1.0.

tập tin wrapper gradle của tôi là:

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 

Trả lời

46

Hoặc chuyển vào android đóng cửa, hoặc sử dụng android.packagingOptions nơi bạn có nó, và xem giúp.

+1

sử dụng 'android.packingoptions' đã hoạt động. Tôi thực sự ban đầu đã có nó trong 'android' bao vây và nó nói rằng một cái gì đó về' appExtentions' không thể được áp dụng cho 'packingOptions' (diễn giải). Nhưng hey ... lựa chọn thứ hai làm việc rất cảm ơn! – KickingLettuce

+2

Di chuyển vào cửa sổ android đã hoạt động cho tôi. Cảm ơn rất nhiều! – HostMyBus

+0

Di chuyển đến đóng cửa android cũng làm việc cho tôi. Được kéo tóc của tôi ra bởi vì mặc dù tôi đã có hơn một thập kỷ phát triển java dưới vành đai của tôi, tôi là một tổng số newbie khi nói đến Gradle. Cảm ơn rất nhiều! – BMB

Các vấn đề liên quan