Wisozk Holo 🚀

Android Gradle plugin 070 duplicate files during packaging of APK

February 16, 2025

Android Gradle plugin 070 duplicate files during packaging of APK

Android builders are perpetually striving for ratio and show successful their apps. Nevertheless, the travel is frequently paved with surprising roadblocks. 1 specified hurdle that builders often brush, particularly once utilizing older variations of the Android Gradle plugin similar zero.7.zero, is the dreaded “duplicate information throughout packaging of APK” mistake. This irritating content tin halt your improvement procedure and pb to hours of debugging. This article delves into the causes of this mistake, offers applicable options, and presents preventative measures to guarantee a smoother improvement education. We’ll research champion practices and methods to aid you navigate this communal situation and support your Android tasks connected path.

Knowing the Duplicate Information Mistake

The “duplicate records-data throughout packaging of APK” mistake arises once the Gradle physique scheme detects aggregate situations of the aforesaid record inside your task’s dependencies oregon origin units. This struggle prevents the scheme from appropriately assembling the last APK, arsenic it can’t find which interpretation of the record to see. This usually happens once antithetic room dependencies see the aforesaid record, oregon once a record is inadvertently positioned successful aggregate directories inside your task. Knowing the underlying causes is important for effectual troubleshooting.

Ideate 2 libraries, some indispensable for your task, all containing a antithetic interpretation of the aforesaid inferior people. This struggle straight leads to the duplicate records-data mistake. Likewise, if you unintentionally spot a assets record, similar an representation, successful some your chief and debug origin units, the physique scheme volition emblem this duplication.

This content tin beryllium peculiarly prevalent with older Gradle plugin variations similar zero.7.zero, wherever dependency direction was little blase. Piece newer variations person improved struggle solution mechanisms, knowing the base causes stays indispensable for builders running with bequest initiatives oregon encountering akin points.

Communal Causes and Options

Respective communal situations pb to duplicate records-data. 1 predominant offender is conflicting dependencies. For illustration, 2 antithetic libraries mightiness see antithetic variations of the aforesaid logging inferior. Resolving this frequently entails excluding the conflicting record from 1 of the dependencies successful your physique.gradle record.

Different communal origin is inadvertently putting the aforesaid record successful aggregate origin units (e.g., chief and debug). Cautious formation of your task’s record construction is important present. Guarantee all record resides successful the due listing and debar pointless duplication.

Generally, the content stems from improper assets merging. Android Workplace presents instruments to aid negociate assets conflicts. Using these instruments tin streamline the procedure and forestall duplicate records-data from creeping into your APK.

  • Reappraisal your dependencies cautiously.
  • Form your task’s record construction efficaciously.

Stopping Duplicate Information

Proactive measures tin importantly trim the hazard of encountering duplicate records-data. Implementing a sturdy dependency direction scheme is cardinal. Instruments similar Gradle’s dependency solution methods tin aid you power which variations of libraries are included successful your task, minimizing conflicts.

Commonly reviewing your task’s record construction and guaranteeing information are positioned successful the accurate directories is different crucial pattern. This elemental measure tin forestall galore duplicate record points from arising successful the archetypal spot. Using a accordant naming normal for assets tin besides aid debar unintentional duplication.

Staying ahead-to-day with the newest variations of the Android Gradle plugin tin besides aid. Newer variations frequently see enhancements successful dependency direction and struggle solution, minimizing the probability of encountering this mistake.

Champion Practices for a Cleanable Physique

Sustaining a cleanable and organized task is cardinal for stopping physique points. Frequently reviewing your dependencies, utilizing a accordant record construction, and adhering to naming conventions tin importantly trim the hazard of duplicate records-data. Using a modular task structure tin additional heighten formation and reduce conflicts.

Leveraging instruments similar Lint tin besides aid place possible points aboriginal connected. Lint performs static investigation of your codification and assets, flagging possible issues specified arsenic duplicate records-data oregon unused assets. Integrating Lint into your physique procedure tin importantly better the choice and stableness of your exertion.

Moreover, using a interpretation power scheme similar Git and committing modifications often permits you to easy revert to former states if errors originate. This offers a condition nett and facilitates simpler debugging.

  1. Reappraisal dependencies.
  2. Form record construction.
  3. Usage Lint.

Larn much astir Android improvement champion practices.“Cleanable codification and appropriate dependency direction are important for avoiding physique points successful Android improvement.” - Android Improvement Adept

Leveraging Gradle’s Exclude Characteristic

Gradle offers a almighty mechanics to exclude circumstantial information from dependencies. This is peculiarly utile once dealing with conflicting libraries. By utilizing the exclude clause successful your physique.gradle record, you tin forestall circumstantial information from being included successful the last APK, resolving duplication points.

Using Android Workplace’s Assets Merger

Android Workplace’s assets merger helps negociate assets conflicts by offering choices to prioritize circumstantial sources oregon specify merge guidelines. This permits you to power however sources are mixed throughout the physique procedure, stopping duplicate record errors.

Often Requested Questions

Q: However bash I place the circumstantial duplicate information?

A: The Gradle physique mistake communication normally signifies the names of the duplicate records-data. You tin besides usage the –data oregon –debug flags with Gradle to acquire much elaborate output throughout the physique procedure, serving to pinpoint the origin of the duplication.

Efficiently addressing the “duplicate records-data throughout packaging of APK” mistake is important for streamlined Android improvement. By knowing the causes, implementing preventative measures, and using the correct instruments, you tin navigate this communal situation efficaciously. Prioritizing a cleanable and organized task construction, mixed with a strong dependency direction scheme, volition finally lend to a much businesslike and little mistake-susceptible improvement procedure. Present, equipped with this cognition, you tin sort out your Android tasks with assurance and guarantee smoother cruising connected your improvement travel. Research assets similar Android Builders and Gradle documentation to additional heighten your knowing. Besides, see becoming a member of on-line communities and boards similar Stack Overflow to link with chap builders and stock champion practices. This collaborative attack tin importantly heighten your job-fixing capabilities and lend to a thriving Android improvement assemblage.

  • Dependency Direction
  • Assets Conflicts

Question & Answer :
Utilizing Android Gradle plugin zero.7.zero with the pursuing physique.gradle:

buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.instruments.physique:gradle:zero.7.zero' } } use plugin: 'android' repositories { maven { url "https://android-rome-provender-scholar.googlecode.com/svn/maven2/releases" } maven { url "http://dl.bintray.com/populov/maven" } mavenCentral() } android { compileSdkVersion 19 buildToolsVersion '18.1.1' defaultConfig { minSdkVersion 9 targetSdkVersion 19 } buildTypes { merchandise { runProguard actual proguardFile getDefaultProguardFile('proguard-android-optimize.txt') } } productFlavors { defaultFlavor { proguardFile 'proguard-guidelines.txt' } } sourceSets { instrumentTest.setRoot('src/instrumentTest') } } configurations { apt } ext.androidAnnotationsVersion = '2.7.1'; dependencies { compile 'com.android.activity:activity-v4:18.zero.zero' compile 'com.viewpagerindicator:room:2.four.1@aar' compile 'com.google.codification.android-rome-provender-scholar:android-rome-provender-scholar:1.zero.zero-r2' compile 'org.jdom:jdom:1.1.1-android-fork' apt "com.googlecode.androidannotations:androidannotations:${androidAnnotationsVersion}" compile "com.googlecode.androidannotations:androidannotations-api:${androidAnnotationsVersion}" compile 'com.google.codification.gson:gson:2.2.four' compile 'com.j256.ormlite:ormlite-android:four.forty seven' compile 'com.j256.ormlite:ormlite-center:four.forty seven' compile 'org.springframework.android:outpouring-android-center:1.zero.1.Merchandise' compile 'org.springframework.android:outpouring-android-remainder-template:1.zero.1.Merchandise' compile 'com.prolificinteractive:actionbarsherlock:four.three.1@aar' compile 'com.google.codification.geocoder-java:geocoder-java:zero.15' compile information('libs/CWAC-Pager.jar') } android.applicationVariants.each { variant -> aptOutput = record("${task.buildDir}/origin/apt_generated/${variant.dirName}") println "****************************" println "variant: ${variant.sanction}" println "manifest: ${variant.processResources.manifestFile}" println "aptOutput: ${aptOutput}" println "****************************" variant.javaCompile.doFirst { println "*** compile doFirst ${variant.sanction}" aptOutput.mkdirs() variant.javaCompile.choices.compilerArgs += [ '-processorpath', configurations.apt.getAsPath(), '-AandroidManifestFile=' + variant.processResources.manifestFile, '-s', aptOutput ] } } 

provides the mistake Duplicate records-data copied successful APK META-INF/Licence.txt:

Informing: Dependency commons-logging:commons-logging:1.zero.four is ignored for defaultFlavorDebug arsenic it whitethorn beryllium conflicting with the inner interpretation supplied by Android. Successful lawsuit of job, delight repackage it with jarjar to alteration the people packages Informing: Dependency commons-logging:commons-logging:1.zero.four is ignored for defaultFlavorRelease arsenic it whitethorn beryllium conflicting with the inner interpretation offered by Android. Successful lawsuit of job, delight repackage it with jarjar to alteration the people packages Creating properties connected request (a.okay.a. dynamic properties) has been deprecated and is scheduled to beryllium eliminated successful Gradle 2.zero. Delight publication http://gradle.org/docs/actual/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html for accusation connected the alternative for dynamic properties. Deprecated dynamic place: "aptOutput" connected "com.android.physique.gradle.inner.api.ApplicationVariantImpl_Decorated@5705013c", worth: "/Customers/david/Developer...". **************************** variant: defaultFlavorDebug manifest: /Customers/david/Developer/.../physique/manifests/defaultFlavor/debug/AndroidManifest.xml aptOutput: /Customers/david/Developer/.../physique/origin/apt_generated/defaultFlavor/debug **************************** Deprecated dynamic place "aptOutput" created successful aggregate places. **************************** variant: defaultFlavorRelease manifest: /Customers/david/Developer/.../physique/manifests/defaultFlavor/merchandise/AndroidManifest.xml aptOutput: /Customers/david/Developer/.../physique/origin/apt_generated/defaultFlavor/merchandise **************************** :TravelGuard:compileDefaultFlavorDebugNdk Ahead-TO-Day :TravelGuard:preBuild Ahead-TO-Day :TravelGuard:preDefaultFlavorDebugBuild Ahead-TO-Day :TravelGuard:preDefaultFlavorReleaseBuild Ahead-TO-Day :TravelGuard:prepareComProlificinteractiveActionbarsherlock431Library Ahead-TO-Day :TravelGuard:prepareComViewpagerindicatorLibrary241Library Ahead-TO-Day :TravelGuard:prepareDefaultFlavorDebugDependencies :TravelGuard:compileDefaultFlavorDebugAidl Ahead-TO-Day :TravelGuard:compileDefaultFlavorDebugRenderscript Ahead-TO-Day :TravelGuard:generateDefaultFlavorDebugBuildConfig Ahead-TO-Day :TravelGuard:mergeDefaultFlavorDebugAssets Ahead-TO-Day :TravelGuard:mergeDefaultFlavorDebugResources Ahead-TO-Day :TravelGuard:processDefaultFlavorDebugManifest Ahead-TO-Day :TravelGuard:processDefaultFlavorDebugResources Ahead-TO-Day :TravelGuard:generateDefaultFlavorDebugSources Ahead-TO-Day :TravelGuard:compileDefaultFlavorDebugJava *** compile doFirst defaultFlavorDebug /Customers/david/Developer/.../src/chief/java/com/travelguard/work/TravelGuardService.java:fifty three: can not discovery signal signal : people TravelGuardPrefs_ determination: people com.travelguard.work.TravelGuardService TravelGuardPrefs_ travelGuardPrefs; ^ /Customers/david/Developer/.../src/chief/java/com/travelguard/ui/CategoriesActivity.java:14: can not discovery signal signal : people AssistanceFragment_ determination: bundle com.travelguard.ui.fragments import com.travelguard.ui.fragments.AssistanceFragment_; ^ /Customers/david/Developer/.../src/chief/java/com/travelguard/ui/CategoriesActivity.java:sixteen: can't discovery signal signal : people CategoryFragment_ determination: bundle com.travelguard.ui.fragments import com.travelguard.ui.fragments.CategoryFragment_; ^ /Customers/david/Developer/.../src/chief/java/com/travelguard/ui/CategoriesActivity.java:17: can not discovery signal signal : people ContactFragment_ determination: bundle com.travelguard.ui.fragments import com.travelguard.ui.fragments.ContactFragment_; ^ /Customers/david/Developer/.../src/chief/java/com/travelguard/ui/CountriesActivity.java:25: can not discovery signal signal : people TravelGuardPrefs_ determination: bundle com.travelguard.work import com.travelguard.work.TravelGuardPrefs_; ^ /Customers/david/Developer/.../src/chief/java/com/travelguard/ui/CountriesActivity.java:forty four: can not discovery signal signal : people TravelGuardPrefs_ determination: people com.travelguard.ui.CountriesActivity TravelGuardPrefs_ travelGuardPrefs; ^ /Customers/david/Developer/.../src/chief/java/com/travelguard/ui/InstructionsActivity.java:18: can't discovery signal signal : people AssistanceFragment_ determination: bundle com.travelguard.ui.fragments import com.travelguard.ui.fragments.AssistanceFragment_; ^ /Customers/david/Developer/.../src/chief/java/com/travelguard/ui/InstructionsActivity.java:19: can not discovery signal signal : people ContactFragment_ determination: bundle com.travelguard.ui.fragments import com.travelguard.ui.fragments.ContactFragment_; ^ /Customers/david/Developer/.../src/chief/java/com/travelguard/ui/InstructionsActivity.java:21: can not discovery signal signal : people InstructionsFragment_ determination: bundle com.travelguard.ui.fragments import com.travelguard.ui.fragments.InstructionsFragment_; ^ /Customers/david/Developer/.../src/chief/java/com/travelguard/ui/MainActivity.java:36: can't discovery signal signal : people TravelGuardPrefs_ determination: bundle com.travelguard.work import com.travelguard.work.TravelGuardPrefs_; ^ /Customers/david/Developer/.../src/chief/java/com/travelguard/ui/MainActivity.java:forty: can't discovery signal signal : people AssistanceFragment_ determination: bundle com.travelguard.ui.fragments import com.travelguard.ui.fragments.AssistanceFragment_; ^ /Customers/david/Developer/.../src/chief/java/com/travelguard/ui/MainActivity.java:forty one: can not discovery signal signal : people ContactFragment_ determination: bundle com.travelguard.ui.fragments import com.travelguard.ui.fragments.ContactFragment_; ^ /Customers/david/Developer/.../src/chief/java/com/travelguard/ui/MainActivity.java:fifty five: can not discovery signal signal : people TravelGuardPrefs_ determination: people com.travelguard.ui.MainActivity TravelGuardPrefs_ travelGuardPrefs; ^ /Customers/david/Developer/.../src/chief/java/com/travelguard/ui/TermsActivity.java:17: can't discovery signal signal : people TravelGuardPrefs_ determination: bundle com.travelguard.work import com.travelguard.work.TravelGuardPrefs_; ^ /Customers/david/Developer/.../src/chief/java/com/travelguard/ui/TermsActivity.java:23: can't discovery signal signal : people TravelGuardPrefs_ determination: people com.travelguard.ui.TermsActivity TravelGuardPrefs_ travelGuardPrefs; ^ Line: Beginning AndroidAnnotations annotation processing Line: AndroidManifest.xml record recovered: /Customers/david/Developer/.../physique/manifests/defaultFlavor/debug/AndroidManifest.xml Line: Figure of records-data generated by AndroidAnnotations: 22 Line: Producing origin record: com.travelguard.work.SmartTravellerService_ Line: Producing origin record: com.travelguard.work.SmartTravellerWebservice_ Line: Producing origin record: com.travelguard.work.TravelGuardPrefs_ Line: Producing origin record: com.travelguard.work.TravelGuardService_ Line: Producing origin record: com.travelguard.work.TravelGuardWebservice_ Line: Producing origin record: com.travelguard.ui.AdviceActivity_ Line: Producing origin record: com.travelguard.ui.CategoriesActivity_ Line: Producing origin record: com.travelguard.ui.ContactDetailActivity_ Line: Producing origin record: com.travelguard.ui.ContactListActivity_ Line: Producing origin record: com.travelguard.ui.ContactTravelGuardActivity_ Line: Producing origin record: com.travelguard.ui.CountriesActivity_ Line: Producing origin record: com.travelguard.ui.InformationActivity_ Line: Producing origin record: com.travelguard.ui.InstructionsActivity_ Line: Producing origin record: com.travelguard.ui.MainActivity_ Line: Producing origin record: com.travelguard.ui.TermsActivity_ Line: Producing origin record: com.travelguard.ui.TravelGuardActivity_ Line: Producing origin record: com.travelguard.ui.fragments.AdviceDetailFragment_ Line: Producing origin record: com.travelguard.ui.fragments.AdviceFragment_ Line: Producing origin record: com.travelguard.ui.fragments.AssistanceFragment_ Line: Producing origin record: com.travelguard.ui.fragments.CategoryFragment_ Line: Producing origin record: com.travelguard.ui.fragments.ContactFragment_ Line: Producing origin record: com.travelguard.ui.fragments.InstructionsFragment_ Line: Clip measurements: [Entire Processing = 913 sclerosis], [Make Sources = 358 sclerosis], [Extract Manifest = 163 sclerosis], [Procedure Annotations = 158 sclerosis], [Extract Annotations = one hundred twenty sclerosis], [Validate Annotations = eighty two sclerosis], [Discovery R Lessons = 28 sclerosis], Line: Clip measurements: [Entire Processing = zero sclerosis], Line: Clip measurements: [Entire Processing = zero sclerosis], informing: The pursuing choices have been not acknowledged by immoderate processor: '[androidManifestFile]' Line: /Customers/david/Developer/.../src/chief/java/com/travelguard/ui/ContactDetailActivity.java makes use of oregon overrides a deprecated API. Line: Recompile with -Xlint:deprecation for particulars. Line: /Customers/david/Developer/.../src/chief/java/com/travelguard/work/SmartTravellerService.java makes use of unchecked oregon unsafe operations. Line: Recompile with -Xlint:unchecked for particulars. :TravelGuard:preDexDefaultFlavorDebug Ahead-TO-Day :TravelGuard:dexDefaultFlavorDebug :TravelGuard:processDefaultFlavorDebugJavaRes Ahead-TO-Day :TravelGuard:validateDebugSigning :TravelGuard:packageDefaultFlavorDebug Mistake: duplicate records-data throughout packaging of APK /Customers/david/Developer/.../physique/apk/TravelGuard-defaultFlavor-debug-unaligned.apk Way successful archive: META-INF/Licence.txt Root 1: /Customers/david/.gradle/caches/modules-2/information-2.1/commons-httpclient/commons-httpclient/three.1/964cd74171f427720480efdec40a7c7f6e58426a/commons-httpclient-three.1.jar Root 2: /Customers/david/.gradle/caches/modules-2/information-2.1/commons-codec/commons-codec/1.2/397f4731a9f9b6eb1907e224911c77ea3aa27a8b/commons-codec-1.2.jar :TravelGuard:packageDefaultFlavorDebug FAILED Nonaccomplishment: Physique failed with an objection. * What went incorrect: Execution failed for project ':TravelGuard:packageDefaultFlavorDebug'. > Duplicate records-data copied successful APK META-INF/Licence.txt Record 1: /Customers/david/.gradle/caches/modules-2/information-2.1/commons-httpclient/commons-httpclient/three.1/964cd74171f427720480efdec40a7c7f6e58426a/commons-httpclient-three.1.jar Record 2: /Customers/david/.gradle/caches/modules-2/information-2.1/commons-httpclient/commons-httpclient/three.1/964cd74171f427720480efdec40a7c7f6e58426a/commons-httpclient-three.1.jar * Attempt: Tally with --stacktrace action to acquire the stack hint. Tally with --data oregon --debug action to acquire much log output. Physique FAILED Entire clip: 21.957 secs 

Issues have been running good this greeting earlier I up to date Android Workplace. Immoderate concepts?

EDIT: I was capable to briefly hole it by moving instructions similar

zip -d outpouring-android-center-1.zero.1.Merchandise.jar META-INF/announcement.txt 

till each the duplicate errors went distant.

Arsenic of Android Workplace interpretation zero.eight.14

You ought to adhd:

android { packagingOptions { exclude 'META-INF/Licence.txt' exclude 'META-INF/Announcement.txt' exclude '...' } } 

to your physique.gradle record.

Past:

In accordance to remark 14 successful this bug: https://issuetracker.google.com/points/36982149#comment14 this is a bug successful v0.7.zero of the Android Gradle plugin, and is owed to beryllium fastened shortly successful zero.7.1.

Present are the notes from that bug astir the summation for zero.7.1:

zero.7.1 is retired with the hole for this.

The DSL to exclude records-data is:

android { packagingOptions { exclude 'META-INF/Licence.txt' } } 

You tin adhd arsenic galore exclude message arsenic you privation. The worth is the archive way. Nary wildcard oregon glob activity but.

Filenames “Licence.txt” and “Announcement.txt” are lawsuit delicate. Delight attempt retired with “licence.txt” and “announcement.txt” arsenic fine.