'META-INF/DEPENDENCIES' error when add implementation apache library - android

More than one file was found with OS independent path 'META-INF/DEPENDENCIES'
Above error occurs while building when I add implementation Apache lib
dependencies {
compile 'org.apache.httpcomponents:httpmime:4.2.6'
}

Related

How to add separate Android Activities that are incompatible

I'm trying to get two separate views added to an existing Android application. Previously, there were no problems having both of them added, but on the new branch we were provided, they're completely incompatible.
One is the MapBox SDK, which is added with the following lines in the gradle.build file per their documentation:
implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:6.3.0')
implementation ('com.mapbox.mapboxsdk:mapbox-sdk-services:3.3.0')
implementation ('com.mapbox.mapboxsdk:mapbox-android-services:2.2.9')
implementation ('com.mapbox.mapboxsdk:mapbox-android-navigation:0.15.0')
implementation ('com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.15.0')
The other is the MapBox WorldScale AR, created by loading their example scene in Unity, exporting to an Android project, and following this guide to create a library and embed the project: https://medium.com/#davidbeloosesky/embedded-unity-within-android-app-7061f4f473a
The notable line in the build.gradle file for AR is: implementation (project(":WorldViewAR-release"))
As is, I get errors about various parts of Lokio being already included. If I comment out one or the other, it assembles just fine. I've tried the following to exclude them from each other:
implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:6.3.0') {
exclude module: ':WorldViewAR-release'
}
implementation ('com.mapbox.mapboxsdk:mapbox-sdk-services:3.3.0') {
exclude module: ':WorldViewAR-release'
}
implementation ('com.mapbox.mapboxsdk:mapbox-android-services:2.2.9') {
exclude module: ':WorldViewAR-release'
}
implementation ('com.mapbox.mapboxsdk:mapbox-android-navigation:0.15.0') {
exclude module: ':WorldViewAR-release'
}
implementation ('com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.15.0') {
exclude module: ':WorldViewAR-release'
}
implementation ('android.arch.lifecycle:extensions:1.1.1')
implementation (project(":WorldViewAR-release")) {
exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-sdk'
exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-sdk-services'
exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-services'
exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-navigation'
exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-navigation-ui'
}
Additionally, I've tried installing the MapBox SDK in a different Android project and an Android Library module, but then I'm unable to access any of the features in the SDK in the main app.
Am I missing something with adding the exclusions, or is there another way to install the SDK in a separate module that will allow it to be accessible in the main app?

Build failed after adding google cloud storage dependency android

I am added google cloud dependency by
implementation ('com.google.cloud:google-cloud-storage:1.12.0'){
exclude group: 'com.google.guava'
}
but my build is failed with the following error
Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration.
- auto-value-1.2.jar (com.google.auto.value:auto-value:1.2)
I tried by disabling annotation processor
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/project.properties'
}
.................
.........
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath false
}
}
........................
I am getting following error
More than one file was found with OS independent path 'project.properties'
Add this part as dependencies:
compileOnly 'com.google.auto.value:auto-value:1.5.1'
annotationProcessor 'com.google.auto.value:auto-value:1.5.1'

commons-logging defines classes that conflict with classes now provided by Android after Android Studio Update

I have updated Android Studio to version 3 and now seems unable to compile my project previously compiled without errors.
The error message is the follow
Error:Error: commons-logging defines classes that conflict with
classes now provided by Android. Solutions include finding newer
versions or alternative libraries that don't have the same problem
(for example, for httpclient use HttpUrlConnection or okhttp instead),
or repackaging the library using something like jarjar.
[DuplicatePlatformClasses]
The dependencies are
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:27.0.0'
compile 'com.android.support:design:27.0.0'
compile 'com.google.api-client:google-api-client-android:1.23.0' exclude module: 'httpclient'
compile 'com.google.http-client:google-http-client-gson:1.23.0' exclude module: 'httpclient'
compile 'com.google.firebase:firebase-core:11.4.2'
}
and error seems caused by
compile 'com.google.api-client:google-api-client-android:1.23.0' exclude module: 'httpclient'
compile 'com.google.http-client:google-http-client-gson:1.23.0' exclude module: 'httpclient'
I already use exclude module: 'httpclient'
So why It doesn't compile?
Is this a bug of Android Studio 3 and\or included com.android.tools.build:gradle:3.0.0 plugin or I'm missing something? With the previous version no problem to compile exactly the same project.
Add to build.gradle located in app module
configurations {
all {
exclude module: 'httpclient'
}
}
If the problem is with commons-logging then it must be excluded too.
Add the following code in app/build.gradle
configurations {
all {
exclude module: 'httpclient'
exclude module: 'commons-logging'
}
}
Got the same issue. I have done below changes
configurations {
all{
exclude group: 'commons-logging', module: 'commons-logging'
exclude group: 'org.apache.httpcomponents'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'org/apache/http/version.properties'
exclude 'org/apache/http/client/version.properties'
}
You should replace "compile" with "implementation" as it's deprecated in the latest gradle and exlude "org.apache.httpcomponents" from Google api client libraries:
implementation('com.google.api-client:google-api-client-android:1.23.0') {
exclude group: 'org.apache.httpcomponents'
}
implementation('com.google.http-client:google-http-client-gson:1.23.0') {
exclude group: 'org.apache.httpcomponents'
}
this solution was found here:
https://developers.google.com/google-apps/activity/v1/quickstart/android
Run in terminal, inside project folder:
./gradlew app:dependencies > dependencies.txt
Then check dependencies.txt to find who is using conflictive dependencies and act accordingly (check for updates, get rid of it, or use exclude as suggested by #Silverstorm)
If you want to continue with async-http then add below following code only in app/build.gradle
configurations {
all {
exclude module: 'commons-logging'
}
}
As 'org.apache.httpcomponents:httpclient:4.3.3' is deprecated after SDKversion 23 so
replace this:
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
with
compile 'org.apache.httpcomponents:httpclient:4.3.3'
I received these two errors today.
1. commons-logging defines classes that conflict with classes now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, for httpclient use HttpUrlConnection or okhttp instead), or repackaging the library using something like jarjar.
2. httpclient defines classes that conflict with classes now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, for httpclient use HttpUrlConnection or okhttp instead), or repackaging the library using something like jarjar.
After struggling for sometime, I figured that I was using a Firebase library which was causing these errors.
implementation platform('com.google.firebase:firebase-bom:29.2.0')
So, I updated it:
implementation platform('com.google.firebase:firebase-bom:29.2.1')
And Invalidated Caches and Restarted the project and it worked like a charm.
Earlier BOM version of Firebase was also working fine.
implementation platform('com.google.firebase:firebase-bom:29.1.0')
Please don't update Firebase BOM version: 29.2.0
I removed commons-logging as suggested above, of course it crashed on some phone with Fatal Exception: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/commons/logging/LogFactory;. How can Android claim the commons-logging is conflicting with Android API when the Android API doesn't contain any of those classes?!? There is no org.apache.commons.logging at https://developer.android.com/reference/packages :facepalm:
I've added back implementation 'commons-logging:commons-logging:1.0.4' to the build.gradle - Android Studio underlines it with red but gradle compiles happily. :facepalm:
Android :triple_facepalm:
if you are facing this issue because of org.apache.httpcomponents:httpmime dependency, then use this in your app level build.gradle file:
implementation('org.apache.httpcomponents:httpmime:4.5.12') {
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
implementation "org.apache.httpcomponents:httpcore:4.4.13"
I had to join multiple solutions from here. This is what worked for me:
configurations {
all*.exclude group: 'com.google.guava', module: 'listenablefuture'
configureEach {
exclude module: 'httpclient'
exclude module: 'commons-logging'
exclude group: 'commons-logging', module: 'commons-logging'
exclude group: 'org.apache.httpcomponents'
}
}
Add this then sync your gradle
configurations {
all*.exclude group: 'com.google.guava', module: 'listenablefuture'
all*.exclude module: 'httpclient'
all*.exclude module: 'commons-logging'
}
in my case android studio couldn't recognize "httpclient"
so i couldn't use #Silverstorm answer.
instead found another answer:
Error: json defines classes that conflict with classes now provided by Android
which implies to add below could in app build.gradle:
configurations {
all {
exclude group: 'org.json', module: 'json'
}
}

Error is Duplicate files copied in META-INF/LICENSE jackson files

gradle error
gradle file
These are my gradle console error and file as well
Suggest new ideas to resolve the error, I tried all previous solutions, didn't work.
You should use 10.2.0 instead of 10.0.1
No Need
compile 'com.firebase:firebase-client-android:2.5.2' // Remove this
Do this
compile 'com.google.firebase:firebase-auth:10.2.0'
compile "com.google.firebase:firebase-database:10.2.0"
Then
android {
.....
packagingOptions{
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
}
Finally Clean-Rebuild and Run .

How to resolve Duplicate files copied in APK META-INF/rxjava.properties

I am using rxjava and rxvolley on my android aplication. When I try to run it I get this error
Execution failed for task ':testapp:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/rxjava.properties
File1: C:\Users\Daniel\.gradle\caches\modules-2\files-2.1\io.reactivex\rxjava\1.1.0\748f0546d5c3c27f1aef07270ffea0c45f0c42a4\rxjava-1.1.0.jar
File2: C:\Users\Daniel\.gradle\caches\modules-2\files-2.1\io.reactivex.rxjava2\rxjava\2.0.3\d2f725668bd22e21170381b23f8fbdf72c69d886\rxjava-2.0.3.jar
I have a exclude.gradle file like this
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/rxjava.properties'
exclude 'META-INF/rxjava.PROPERTIES'
exclude 'META-INF/RXJAVA.properties'
exclude 'META-INF/RXJAVA.PROPERTIES'
exclude 'META-INF/rxjava'
exclude 'META-INF/RXJAVA'
}
lintOptions {
abortOnError false
}
}
How can I fix this problem?
I had the same problem. The way I fixed it is adding the packagingOptions in app gradle as described in Duplicated file rxjava.properties
android {
defaultConfig {
}
buildTypes {
}
packagingOptions{
exclude 'META-INF/rxjava.properties'
}
}
I had the same issue.
In my case I am using Retrofit2 but I assume that the issue is with the rx libraries
This is the build.gradle (module:app) I am using and in my case works.
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
compile 'io.reactivex:rxandroid:1.1.0' //<-use this
compile 'io.reactivex:rxjava:1.1.3' //<-use this
compile 'com.squareup.okhttp3:okhttp:3.1.2'
compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'
Anyway there is one better solution as you can see on the top
I also have the same problem but easily removed duplicated "comment" all Rxjava related dependencies that it doesn't use in my code.
//RxJava removes or comment duplicated and not used dependencies.
// implementation 'com.squareup.retrofit2:adapter-rxjava:2.4.0'
// implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
// implementation 'io.reactivex.rxjava2:rxjava:2.1.13'
I encountered the same issue and fixed it by putting below code in app/build.gradle file. Please note that you have to put '*' at the end of path to exclude all the files inside the folder. You will have to change the path of files to be excluded in the below code based on error description.
compileSdkVersion 25
buildToolsVersion "24.0.3"
packagingOptions {
exclude 'com/google/appengine/repackaged/org/apache/commons/codec/language/bm/*'
exclude 'com/google/appengine/repackaged/org/codehaus/jackson/impl/*'
exclude 'com/google/appengine/repackaged/org/apache/commons/codec/language/*'
}
I had this issue today and fixed this problem
compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.squareup.retrofit2:converter-gson:2.2.0'
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
//RxJava dependencies
compile 'io.reactivex.rxjava2:rxandroid:2.0.0'
compile 'io.reactivex.rxjava2:rxjava:2.0.2'
compile 'org.reactivestreams:reactive-streams:1.0.0'
I also have this problem ,I also used the same method as you ,but because I hava two module ,I only chang it in the module which dependency Rxjava,Finally I I fixed it is adding the packaginOptions in app gradle
packagingOptions {
exclude 'META-INF/rxjava.properties'
}
If you are facing this issue in 2019 and above this is most probably because you are using the deprecated RxJava 2 CallAdapter.Factory ie
com.jakewharton.retrofit:retrofit2-rxjava2-adapter
you will have to remove that dependency and add this
implementation 'com.squareup.retrofit2:adapter-rxjava2:latest.version'
please get the latest version from here
Add this code in build.gradle.app
android {
...
...
...
packagingOptions {
exclude 'META-INF/rxjava.properties'
}
}

Categories

Resources