I have been struggling for a while now to get a gradle file that will build with the following:
compile('com.amazonaws:aws-android-sdk-auth-userpools:2.6.0#aar') { transitive = true; }
compile('com.amazonaws:aws-android-sdk-auth-ui:2.6.0#aar') { transitive = true; }
compile 'com.android.support:design:<absolutely any version>'
No matter what version I use, I can't get the three things to play nicely. The first two were taken directly off of amazons tutorial on integrating user sign-in (http://docs.aws.amazon.com/mobile-hub/latest/developerguide/add-aws-mobile-user-sign-in-email-and-password.html). The last I am using for the rest of the app (seems like a pretty standard, expected library to compile with???).
I have tried the following versions for com.android.support:design:
24.2.0: leads to the error:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 24.2.0, 23.0.0
23.0.0 also leads to the same above error.
Note:
Commenting out the userpools library allows v23.0.0 to work. Commenting out the auth-ui library allows v24.2.0 to work...
Exclude the Android support libraries that are part of the dependencies.
For example, if your compileSdkVersion and targetSdkVersion are 24, you would be requiring the 24.+ support libraries
In build.gradle, do the following changes under dependencies:
.......
compile 'com.android.support:appcompat-v7:24.+'
compile 'com.android.support:support-v4:24.+'
compile 'com.android.support:design:24.+'
.......
compile('com.amazonaws:aws-android-sdk-auth-ui:2.6.0#aar') {
transitive = true;
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.android.support', module: 'cardview-v7'
}
compile('com.amazonaws:aws-android-sdk-auth-userpools:2.6.0#aar') {
transitive = true;
exclude group: 'com.android.support', module: 'support-v4'
}
Related
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?
implementation 'com.android.support:appcompat-v7:27.1.1'
All com.android.support libraries must use exact same version specification. Mixing versions can lead to runtime crashes.
Found versions 27.1.1, 27.1.0. Examples include com.android.support:animated-vector-drawable:27.1.1 and com.android.support:cardview-v7:27.1.0
Please help me to solve this problem...
The issue usually rises when third-party libraries are using an older version of the support library. You can get over it by looking at which lib is using the older version and add this to your build gradle on the app level
implementation "com.android.support:animated-vector-drawable:27.1.1"
implementation "com.android.support:cardview-v7:27.1.1"
In my case, it was the Facebook SDK so I replace this
implementation 'com.facebook.android:facebook-android-sdk:4.23.0'
with
implementation('com.facebook.android:facebook-android-sdk:4.23.0') {
exclude group: 'com.android.support', module: 'animated-vector-drawable'
exclude group: 'com.android.support', module: 'cardview-v7'
exclude group: 'com.android.support', module: 'customtabs'
}
and all my warnings disappeared
27.1.1 is the latest version of the Android support library. So just replace the version to 27.1.1 for all com.android.support dependencies you're using. No reason not to.
I completed the answers of Mukesh Solanki with:
dependencies{
implementation ('com.facebook.android:facebook-android-sdk:4.36.1'){
// contains com.android.support:v7:27.0.2, included required com.android.support.*:27.1.1 modules
exclude group: 'com.android.support', module: 'animated-vector-drawable'
exclude group: 'com.android.support', module: 'cardview-v7'
exclude group: 'com.android.support', module: 'customtabs'
}
implementation "com.android.support:animated-vector-drawable:27.1.1"
implementation "com.android.support:cardview-v7:27.1.1"
implementation "com.android.support:customtabs:27.1.1"
}
}
And all my problem when away
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'
}
}
I am implementing facebook integration in my project but I am stuck as I add facebook sdk dependency in my project it gives me an error.
When i am going to add facebook sdk dependencies in build.gradle, it gives me error of mixing version.
The Facebook SDK for Android is using support libraries version 25.3.1, so you have to exclude them to use the most recent support libraries:
Something like:
compile ('com.facebook.android:facebook-android-sdk:4.26.0') {
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.android.support', module: 'cardview-v7'
exclude group: 'com.android.support', module: 'customtabs'
}
Otherwise you have to use the support libraries v.25.3.1 instead of 26.+.
Use:
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
...
Try adding the specific Version of the implementation, go to this link https://developers.facebook.com/docs/android/downloads/
and add latest version. If the error still persists you may have to lower the version number. At the time of answering this, 4.31.0 is the latest version, but 4.29.0 worked for me.
I have an old eclipse based project , and i converted it to android studio based. The convertion success, but i have problem when adding other dependency, first i get error java.exe finished with non-zero exit value 2, because of duplicate dependency support v4, and i try to exlude modul support v4, but now im getting java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV14
this is my build.gradle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':SlidingMenu')
compile project(':PhotoView')
compile project(':viewpager')
compile project(':StackBlur')
compile project(':FacebookSDK')
compile files('libs/LibAllShareInterface_2.0.0.jar')
// Exclude module support-v4 to remove duplicate
compile ('com.android.support:appcompat-v7:22.2.0') { exclude module: 'support-v4' }
compile('com.android.support:design:22.2.0') { exclude module: 'support-v4' }
compile('com.squareup.picasso:picasso:2.5.2') { exclude module: 'support-v4' }
compile('com.android.support:recyclerview-v7:21.0.0') { exclude module: 'support-v4' }
compile('com.android.support:cardview-v7:22.2.0') { exclude module: 'support-v4' }
compile('com.android.support:support-annotations:22.2.0') { exclude module: 'support-v4' }
}
Any help will be appreciated
Well although I am not gradle expert and I'm experiencing some problems myself, I was able to reproduce an error complaining about appcompat-v4, using your dependencies.
It seems that you are completely excluding support-v4 from all your dependencies, and since support-v4 is required, you must either specify it as a dependency separately, or change this:
compile ('com.android.support:appcompat-v7:22.2.0') { exclude module: 'support-v4' }
to this:
compile ('com.android.support:appcompat-v7:22.2.0')
so you don't exclude support-v4 completely from your project.
I did the second and the project could build (A sample project with just those dependencies defined).