2017-05-22 198 views
0

我在Windows 8上使用Android Studio 2.3.2,並在構建應用程序時發生錯誤。 首先,gradle這個生成過程中,當您啓動IDE,我有這些警告:DuplicateFileException當在Android Studio中構建apk時

Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.6 is 
ignored for debug as it may be conflicting with the internal version 
provided by Android. 
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.6 is 
ignored for release as it may be conflicting with the internal version 
provided by Android. 
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.6 is 
ignored for debugAndroidTest as it may be conflicting with the internal 
version provided by Android. 
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.6 is 
ignored for debug as it may be conflicting with the internal version 
provided by Android. 
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.6 is 
ignored for release as it may be conflicting with the internal version 
provided by Android. 
的APK構建過程中

然後有2個警告,但此錯誤:

Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.6 is 
ignored for release as it may be conflicting with the internal version 
provided by Android. 
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.6 is 
ignored for debug as it may be conflicting with the internal version 
provided by Android. 

Error:Execution failed for task 
':app:transformResourcesWithMergeJavaResForDebug'. 
> com.android.build.api.transform.TransformException: 
com.android.builder.packaging.DuplicateFileException: Duplicate files copied 
in APK META-INF/LICENSE 
File1: C:\Users\giorgia\.gradle\caches\modules-2\files- 
2.1\com.fasterxml.jackson.core\jackson- 
core\2.2.3\1a0113da2cab5f4c216b4e5e7c1dbfaa67087e14\jackson-core-2.2.3.jar 
File2: C:\Users\giorgia\.gradle\caches\modules-2\files- 
2.1\com.fasterxml.jackson.core\jackson- 
annotations\2.2.3\527fece4f23a457070a36c371a26d6c0208e1c3\jackson- 
annotations-2.2.3.jar 
File3: C:\Users\giorgia\.gradle\caches\modules-2\files- 2.1\org.apache.httpcomponents\httpmime\4.3.6\cf8bacbf0d476c7f2221f861269365b664 
47f7ec\httpmime-4.3.6.jar 
File4: C:\Users\giorgia\.gradle\caches\modules-2\files- 
2.1\com.fasterxml.jackson.core\jackson- 
databind\2.2.3\3ae380888029daefb91d3ecdca3a37d8cb92bc9\jackson-databind- 
2.2.3.jar 
File5: C:\Users\giorgia\.gradle\caches\modules-2\files- 2.1\org.apache.httpcomponents\httpcore\4.4.3\e876a79d561e5c6207b78d347e198c8c45 
31a5e5\httpcore-4.4.3.jar 
+0

您能不能告訴你的build.gradle? – Henry

回答

0

您需要使用packaginOptions在 '應用' 的build.gradle文件,您buildToolsVersion後:

packagingOptions { 
    exclude 'META-INF/LICENSE' 
} 
0

嘗試添加該到你buiild.gradle

它來,因爲你不排除META-INF/LICENSE文件存在於你的依賴

packagingOptions { 
    exclude 'META-INF/NOTICE' // will not include NOTICE file 
    exclude 'META-INF/LICENSE' // will not include LICENSE file 
    // as noted by @Vishnuvathsan you may also need to include 
    // variations on the file name. It depends on your dependencies. 
    // Some other common variations on notice and license file names 
    exclude 'META-INF/notice' 
    exclude 'META-INF/notice.txt' 
    exclude 'META-INF/license' 
    exclude 'META-INF/license.txt' 
} 

OR的多個使multiDex

defaultConfig { 

      // Enabling multidex support. 
      multiDexEnabled true 
     } 
+0

我將你的代碼添加到build.gradle文件中,但它仍然給我2個重複的文件: File1:C:\ Users \ giorgia \ .gradle \ caches \ modules-2 \ files-2.1 \ org.apache.httpcomponents \ httpcore \ 4.4.3 \ b31526a230871fbe285fbcbe2813f9c0839ae9b0 \ httpcore-4.4.3.jar File2:C:\ Users \ giorgia \ .gradle \ caches \ modules-2 \ files-2.1 \ org.apache.httpcomponents \ httpmime \ 4.5.2 \ 22b4c53dd9b6761024258de8f9240c3dce6ea368 \ httpmime-4.5.2.jar –

+0

您是否嘗試過,刪除App文件夾中的生成文件夾,然後重建項目? –

+0

只是試了一下,沒有什麼變化......我想我會放棄在這個Spoonacular API –

相關問題