Duplicate Files While Packing APK app-debug-unaligned.apk

I got this error Duplicate files during packaging of APK app-debug-unaligned.apk when I put 2 jar files:

  • httpclient-4.3.5.jar

  • httpmime-4.3.5.jar

    to the libs folder after Sync with Gradle and Run .

If user 1 jar file is httpmime-4.3.5.jar , I will not get this error.

Please help me how to avoid this error and can still use 2 jar files in the above,

Thank,

p / s: I am using Android Studio version 0.8.6.

Error Detail

Error: duplicate files during APK packaging ... \ application \ assembly \ outputs \ APK \ debug application unaligned.apk Archive path: META-INF / DEPENDENCE Origin 1: ... \ app \ libs \ httpclient-4.3. 5.jar Origin 2: ... \ app \ libs \ httpmime-4.3.5.jar

build.gradle

 android { compileSdkVersion 20 buildToolsVersion '20.0.0' defaultConfig { applicationId 'com.app' minSdkVersion 9 targetSdkVersion 20 versionCode 1 versionName '1.0' } buildTypes { release { runProguard false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } productFlavors { } packagingOptions { exclude 'META-INF/LICENSE.txt' } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile 'com.android.support:support-v4:20.0.0' compile 'com.android.support:appcompat-v7:20.0.0' compile 'com.google.android.gms:play-services:5.2.08' compile 'com.viewpagerindicator:library:2.4.1@aar' compile 'de.hdodenhof:circleimageview:1.2.0' compile files('libs/httpmime-4.3.5.jar') } 

UPDATE I changed from compile files('libs/httpmime-4.3.5.jar') to use Maven Link. I got the same error again after you made 2 maven connection:

  compile 'org.apache.httpcomponents:httpmime:4.4-alpha1' compile 'org.apache.httpcomponents:httpcore:4.4-alpha1' 

This is a warning

Warning. The dependency org.apache.httpcomponents: httpclient: 4.4-alpha1 is ignored for debugging, as this may contradict the internal version provided by Android. If a problem occurs, repack it with jarjar to modify the class packages.

Warning: Dependency on org.apache.httpcomponents: httpclient: 4.4-alpha1 is ignored for release because it may contradict the internal version provided by Android. If a problem occurs, repack it with jar to change the class packages.

Please help me fix it.

SOULITION I know a good answer by adding these lines, fixing the Duplicate files error:

 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' } 
+49
android android-studio jar
Aug 25 '14 at 10:01
source share
5 answers

You can replace compile files('libs/httpmime-4.3.5.jar') with this compiler 'org.apache.httpcomponents:httpmime:4.3.5' .

You also duplicate the dependencies compile fileTree(include: ['*.jar'], dir: 'libs') already includes compile files('libs/httpmime-4.3.5.jar')

+10
Aug 25 '14 at 10:25
source share

update your build.gradle and add the following lines

 android{ . . . packagingOptions { exclude 'META-INF/license.txt' exclude 'META-INF/LICENSE' exclude 'META-INF/notice.txt' exclude 'META-INF/NOTICE' } } 

this will fix this error. I got the same error that I fixed it.

+8
Dec 09 '15 at 11:12
source share

Update this in the build.gradle file.

  packagingOptions { exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' } 
0
Sep 24 '15 at 6:39
source share

I updated gradle, now it works

packaging Options {exclude "META-INF / DEPENDENCIES" exclude 'META-INF / LICENSE' exclude 'META-INF / LICENSE.txt' exclude "META-INF / NOTICE.txt"}

0
Apr 16 '17 at 4:02 on
source share

add the code below to the dependencies

compilation group: 'org.apache.httpcomponents', name:' httpclient-android ', version:' 4.3.5 'compile (group:' org.apache.httpcomponents', name: 'httpmime', version: '4.3.5 ') {exclude module:' org.apache.httpcomponents: httpclient '}

now if you run this, it will show you why it says that the duplicate may be due to META-INF / NOTICE, META-INF / LICENSE, add that run again first, it may display a different type. add everything as shown below in the Android section packaging Options {exclude 'META-INF / LICENSE.txt' exclude 'META-INF / NOTICE' exclude 'META-INF / LICENSE'}

this will definitely solve your problem.

delete the entire dependency file from the system before building.

-3
Feb 25 '15 at 14:10
source share



All Articles