Share: Android Studio imports third-party jar packages, repeated loading error resolution.

Source: Internet
Author: User

Recently in the use of HTTP need to implement file upload, although you can use httpurlconnection to achieve the native post upload, but this seems inefficient, and then choose the online more than httpclient by HttpPost way to upload files, The use of this method requires a jar of Apache, Httpmime-xxx.jar This package is also dependent on the Httpcore-xxx.jar, after the normal import of two jar package, filled with joy ready to mutate, but an egg pain error jumped out:

Error:Duplicate files during packaging of APK D:\develop\android\workspace\androidstudio\mLtimeline\app\build\outputs\apk\app-Debug-unaligned.apkPath InchArchive:META-Inf/NOTICEOrigin 1:D:\develop\android\workspace\androidstudio\mLtimeline\app\libs\httpcore-4.3.JarOrigin 2:D:\develop\android\workspace\androidstudio\mLtimeline\app\libs\httpmime-4.3.1.jar Youcan ignore those filesInchYour build.Gradle:Android{Packagingoptions{Exclude' Meta-inf/dependencies 'Exclude' Meta-inf/notice ' exclude  ' meta-inf/license '  }  }   Error :  execution  Failed  for  task  ': App:packagedebug ' .  ;   Duplicate  files copied  in  APK META - INF / NOTICE  File   1 :  D :  \develop\android\workspace\androidstudio\m  ltimeline  \ App\libs\httpcore - 4.3 .  Jar  File   2 :  D :  \develop\android\workspace\androidstudio\m  Ltimeline  \app\libs\httpcore - 4.3 .  Jar                   

Look at the literal meaning that the jar is loaded repeatedly, and then you need to add something to the project's plainclothes file, since you can understand it, just follow the hint.
Open the project's Build.gradle file, add the Hint section under the Android tab,

Then sync Gradle: After modifying the gradle compiled file androidstudio the upper right corner will be prompted to sync Gradle button, you can directly click on the synchronization gradle configuration, if not available in the menu bar: Tools–android–sync Project with Gradle Files for synchronization
Sync complete, continue compiling, duang~~
Still that mistake, but this time the hint joins the content to be different, continues to add under Packagingoptions, continues to compile synchronously, duang~~
Continue ~ ~ Duang Duang Duang ~ ~
OK Duang after three times is not a problem, in the compilation configuration file is added to these lines of code

Resolve duplicate load third party that jar package problem  {' meta-inf/dependencies 'meta-inf/notice 'meta-inf/license '} 

This is also different depending on the jar package that is added, but it should be solved as soon as you follow the instructions!

    • Technology Blog: Love encryption Launch XcodeGhost solution, protect iOS system app security
    • Technology Blog: Programmer's Choice: several new open source tools in mobile development
    • Technical Blog: A brief analysis on the development tools of Gameplaykit Apple hand Tour

Share: Android Studio imports third-party jar packages, repeated loading error resolution.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.