Dealing with the dreaded āMuch than 1 record was recovered with OS autarkic way āMETA-INF/Licenceāā mistake successful your Android task tin beryllium a existent headache. This irritating content sometimes arises once aggregate dependencies successful your task see the aforesaid licence record, inflicting a struggle throughout the physique procedure. Knowing the base origin and implementing effectual options is important for seamless improvement. This usher supplies a heavy dive into the job, providing applicable options and preventive measures to support your initiatives moving easily.
Knowing the āMETA-INF/Licenceā Struggle
The āMETA-INFā listing inside a JAR record comprises meta-accusation astir the record, together with licensing particulars. Once aggregate libraries see the aforesaid āLicenceā record successful this listing, the physique scheme tināt find which 1 to usage, triggering the mistake. This frequently occurs once antithetic variations of the aforesaid room, oregon libraries with akin dependencies, are included successful your task.
Ideate gathering a home with 2 units of blueprints that struggle connected cardinal parts. Thatās basically what this mistake represents: conflicting directions for your physique procedure. Figuring out the conflicting libraries is the archetypal measure in the direction of resolving the content.
Instruments similar Gradleās dependency actor tin beryllium invaluable successful pinpointing the wrongdoer libraries. By visualizing your taskās dependencies, you tin rapidly place which ones are contributing to the āMETA-INF/Licenceā struggle.
Resolving the Struggle: Applicable Options
Respective methods tin beryllium employed to code this content efficaciously. 1 communal attack entails excluding the conflicting āLicenceā record from circumstantial dependencies utilizing Gradleās exclude directive. This tells the physique scheme to disregard the duplicate records-data, stopping the struggle.
Different resolution is using packagingOptions inside your module-flat physique.gradle record. This permits you to specify however duplicate information ought to beryllium dealt with, specified arsenic selecting the archetypal prevalence oregon merging them if imaginable. This attack affords much flexibility and power complete the physique procedure.
For illustration, you tin adhd the pursuing to your physique.gradle
record:
android { packagingOptions { exclude 'META-INF/Licence' // oregon pickFirst 'META-INF/Licence' } }
Stopping Early Conflicts: Champion Practices
Prevention is ever amended than remedy. Frequently reviewing your taskās dependencies and protecting them ahead-to-day is important for avoiding specified conflicts. Utilizing a dependency direction implement similar Gradle helps streamline this procedure.
Using a accordant versioning scheme for your dependencies ensures compatibility and minimizes the hazard of conflicting information. This entails specifying exact variations for your libraries instead than relying connected dynamic versioning.
By adhering to these practices, you tin make a much unchangeable and maintainable task, lowering the probability of encountering the āMETA-INF/Licenceā mistake successful the early.
Precocious Troubleshooting Strategies
Typically, the struggle mightiness beryllium profoundly embedded inside transitive dependencies, making it tougher to pinpoint. Successful specified circumstances, utilizing the --information
oregon --debug
flags with your Gradle physique bid tin supply elaborate logs, serving to you hint the origin of the struggle.
Analyzing these logs tin uncover which circumstantial libraries are inflicting the content, permitting you to use focused exclusion guidelines oregon another solution methods. This deeper flat of investigation is peculiarly utile for analyzable initiatives with many dependencies.
Retrieve to seek the advice of authoritative documentation and on-line assets for much precocious troubleshooting ideas and methods. Assemblage boards and Q&A websites tin besides supply invaluable insights from skilled builders who person encountered akin points.
Often Requested Questions (FAQ)
Q: What if excluding the āLicenceā record causes ineligible points?
A: Piece excluding the record itself removes the physique mistake, guarantee you comply with the licenses of the libraries you usage. Keep a abstracted evidence of the licenses to debar immoderate ineligible issues.
[Infographic Placeholder: Visualizing the struggle and solution procedure]
- Usually replace dependencies to decrease conflicts.
- Usage Gradleās dependency actor to place conflicting libraries.
- Place conflicting libraries utilizing Gradleās dependency actor.
- Instrumentality exclusion guidelines oregon packagingOptions successful your physique.gradle record.
- Confirm the resolution by rebuilding your task.
By knowing the underlying causes of the āMETA-INF/Licenceā struggle and implementing the options outlined supra, you tin efficaciously sort out this communal Android improvement hurdle. Accordant dependency direction and proactive troubleshooting volition lend importantly to a smoother improvement education. Research additional sources and assemblage boards similar Stack Overflow for deeper insights and aid. Besides, cheque retired the authoritative Android Builders documentation connected dependency direction. For a applicable usher connected utilizing Gradle, sojourn the Gradle person usher. Donāt fto this mistake stall your advancement ā return act present and support your tasks shifting guardant. Larn much astir resolving dependency conflicts from this insightful article: Dependency Direction Champion Practices.
Question & Answer :
Once I physique my app, I acquire the pursuing mistake:
Mistake: Execution failed for project ā:app:transformResourcesWithMergeJavaResForDebugā. Much than 1 record was recovered with OS autarkic way āMETA-INF/Licenceā
This is my physique.gradle record:
use plugin: 'com.android.exertion' use plugin: 'kotlin-android' android { compileSdkVersion 25 buildToolsVersion "25.zero.2" defaultConfig { applicationId "cn.sz.cyrus.kotlintest" minSdkVersion 14 targetSdkVersion 25 versionCode 1 versionName "1.zero" testInstrumentationRunner "android.activity.trial.runner.AndroidJUnitRunner" javaCompileOptions{ annotationProcessorOptions{ includeCompileClasspath = actual } } multiDexEnabled actual } buildTypes { merchandise { minifyEnabled mendacious proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-guidelines.professional' } } packagingOptions { /* exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/Announcement' exclude 'META-INF/Licence' exclude 'META-INF/Licence.txt' exclude 'META-INF/Announcement.txt' */ } } dependencies { compile fileTree(see: ['*.jar'], dir: 'libs') androidTestCompile('com.android.activity.trial.espresso:espresso-center:2.2.2', { exclude radical: 'com.android.activity', module: 'activity-annotations' }) compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-indicate:$kotlin_version" compile 'com.android.activity:appcompat-v7:25.three.1' testCompile 'junit:junit:four.12' compile 'com.android.activity:plan:25.three.1' compile 'com.android.activity.constraint:constraint-format:1.zero.2' debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1' releaseCompile 'com.squareup.leakcanary:leakcanary-android-nary-op:1.5.1' testCompile 'com.squareup.leakcanary:leakcanary-android-nary-op:1.5.1' compile 'com.github.GrenderG:Toasty:1.2.5' compile 'com.orhanobut:logger:1.15' compile 'io.reactivex.rxjava2:rxandroid:2.zero.1' compile 'com.umeng.analytics:analytics:newest.integration' compile 'ai.api:libai:1.four.eight' compile 'ai.api:sdk:2.zero.5@aar' // api.ai SDK dependencies compile 'com.google.codification.gson:gson:2.eight.zero' compile 'commons-io:commons-io:2.four' compile 'com.android.activity:multidex:1.zero.1' }
Once I adhd this codification to my physique.gradle record:
packagingOptions { exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/Announcement' exclude 'META-INF/Licence' exclude 'META-INF/Licence.txt' exclude 'META-INF/Announcement.txt' }
This mistake would beryllium solved, however different job volition hap. Similar this:
java.lang.NoClassDefFoundError: com.squareup.leakcanary.inner.HeapAnalyzerService astatine com.squareup.leakcanary.LeakCanary.isInAnalyzerProcess(LeakCanary.java:one hundred forty five) astatine cn.sz.cyrus.wemz.TestApplication.onCreate(TestApplication.kt:32)
Who has ideas however to lick this?
You tin adhd this successful yourProject/app/physique.gradle
wrong android{}
. The exclude relation provides the named assets to the database of sources that are not packaged successful the APK.
android { packagingOptions { exclude("META-INF/DEPENDENCIES") exclude("META-INF/Licence") exclude("META-INF/Licence.txt") exclude("META-INF/licence.txt") exclude("META-INF/Announcement") exclude("META-INF/Announcement.txt") exclude("META-INF/announcement.txt") exclude("META-INF/ASL2.zero") exclude("META-INF/*.kotlin_module") } }
The exclude
relation is deprecated successful 7.zero.2 and you ought to usage thing akin to this:
android { ... packagingOptions { assets.excludes.adhd("META-INF/*") } }