2016-05-24 13 views
1

私はアプリケーションで単一のbuild.gradleファイルを使用しています。 バージョン1.6に関しては正常に動作しています。 しかし、これをモジュールを使った位置更新に使用したいと思います。ビルドgradle:メソッドのpackagingOptions()の引数が見つかりませんでしたルートプロジェクト "fasterDev"

apply plugin: 'com.android.application' 
... 

dependencies { 
    compile 'com.google.android.gms:play-services:fp9.0.0' 
} 

ここは私のbuild.gradleです。

buildscript { 
    repositories { 
     mavenCentral() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.1.0' 
    } 
} 
apply plugin: 'android' 

dependencies { 
    compile fileTree(dir: 'libs', include: '*.jar') 
} 

android { 
    compileSdkVersion 15 
    buildToolsVersion "21.1.2" 

    sourceSets { 
     main { 
      manifest.srcFile 'AndroidManifest.xml' 
      java.srcDirs = ['src'] 
      resources.srcDirs = ['src'] 
      aidl.srcDirs = ['src'] 
      renderscript.srcDirs = ['src'] 
      res.srcDirs = ['res'] 
      assets.srcDirs = ['assets'] 
     } 

     // Move the tests to tests/java, tests/res, etc... 
     instrumentTest.setRoot('tests') 

     // Move the build types to build-types/<type> 
     // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... 
     // This moves them out of them default location under src/<type>/... which would 
     // conflict with src/ being used by the main source set. 
     // Adding new build types or product flavors should be accompanied 
     // by a similar customization. 
     debug.setRoot('build-types/debug') 
     release.setRoot('build-types/release') 
    } 

} 

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

build.gradle

このための任意のチュートリアルや提案?

ログ:

org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48) 
Caused by: org.gradle.api.internal.MissingMethodException: Could not find method packagingOptions() for arguments [[email protected]] on root project 'fasterDev'. 
    at org.gradle.api.internal.AbstractDynamicObject.methodMissingException(AbstractDynamicObject.java:68) 

答えて

15

あなたはandroid閉鎖の外側を提供してきました、それはそれはいくつかのルートプロジェクトの方法だと、Gradleのは想定の理由です。

と同じように、android閉鎖に移動:あなたが提案するように私はアンドロイドの内側にこれを置いた場合

android { 
    ... 

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

はあなたの時間との提案のためにありがとうござい.but。私は、 "APKにコピーされた重複ファイル" を取得 &ログインします::あなたのbuild.gradleにそれらのファイルを無視することができます。 \tアンドロイド{ \t packagingOptionsを{ \tは、 'LIB/armeabi-v7a/gdbserverを' を除外 \t} \t} あなたはこれについてもっと提案できますか? – NovusMobile

+1

これは、最初に得た例外が解決され、ビルドスクリプトが正しいことを意味します。提供された設定を改善するだけです。あなたは 'lib/armeabi-v7a/gdbserver'を除外しようとしましたか?これが '.so'ネイティブlibであれば、' exclude'を 'pickFirst'に変更しようとします。これはlibの最初の1つだけの存在を含みます。 – Stanislav

+0

素晴らしい。おめでとう。除外して、pick私は初めてです。これに関する記事がある場合。リンクを共有してください。 – NovusMobile

関連する問題