I have added this line to my build.gradle
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5'
and I want to use MultipartEntityBuilder in my code. However Android studio doesn't add the library to my code.
Can anyone help me with this?
If you are using target SDK as 23 add the below code in your build.gradle
android{
useLibrary 'org.apache.http.legacy'
}
Additional note here: don't try using the gradle versions of those files. They are broken (28.08.15). I tried over 5 hours to get it to work. It just doesn't.
not working:
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
Another thing don't use:
'org.apache.httpcomponents:httpclient-android:4.3.5.1'
It's referring to 21 API level.
The accepted answer does not seem quite right to me. There is no point dragging a different version of HttpMime when one can depend on the same version of it.
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5'
compile (group: 'org.apache.httpcomponents' , name: 'httpmime' , version: '4.3.5') {
exclude module: 'org.apache.httpcomponents:httpclient'
}
Try adding this to your dependencies:
compile 'org.apache.httpcomponents:httpclient:4.4-alpha1'
And generally if you want to use a library and you are searching for the Gradle dependency line you can use Gradle Please
EDIT: Check this one too.
None of the others worked for me. I had to add the following dependency, as explained here
compile group: 'cz.msebera.android' , name: 'httpclient', version: '4.4.1.1'
because I was targeting API 23.
I resolved problem by adding following to my build.gradle file
android {
useLibrary 'org.apache.http.legacy'}
However this only works if you are using gradle 1.3.0-beta2 or greater, so you will have to add this to buildscript dependencies if you are on a lower version:
classpath 'com.android.tools.build:gradle:1.3.0-beta2'
I searched over and over this solution works like a charm ::
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.anzma.memories"
useLibrary 'org.apache.http.legacy'
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: 'httpclient'
}
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
}
I don't know why but (for now) httpclient can be compiled only as a jar into the libs directory in your project.
HttpCore works fine when it is included from mvn like that:
dependencies {
compile 'org.apache.httpcomponents:httpcore:4.4.3'
}
Working gradle dependency
Try this:
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
Related
I am having trouble building my app all of a sudden.
the error:
Error:Execution failed for task
Duplicate files copied in APK lib/x86_64/libogg.so
File1: C:\Users\name\.android\build-cache\72c018be052ae391eef4ab43483d6a04be10a818\output\jni
File2: C:\Users\name\.android\build-cache\425f82e82c18acce2ff0ced2ade670804d31a815\output\jni
I have attempted to fix using packaging options:
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LGPL2.1'
}
entire file
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LGPL2.1'
}
defaultConfig {
applicationId "myappsid"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:support-v4:26'
compile 'com.android.support:support-vector-drawable:26'
compile 'org.apache.commons:commons-io:1.3.2'
compile 'com.google.android.gms:play-services-ads:11.0.4'
compile 'com.ibm.watson.developer_cloud:android-sdk:0.4.2'
compile 'com.ibm.watson.developer_cloud:java-sdk:3.9.1'
testCompile 'junit:junit:4.12'
compile project(':library-release')
}
any help is greatly appreciated. I have tried longer exclude options as well in other posts that I have found but that didn't help either.
You can try using pickFirst in packagingOptions. You need to get the correct package name of libogg.so from File1 or File2:
packagingOptions {
pickFirst 'com/library/name/lib/x86_64/libogg.so'
...
}
UPDATE:
There is a conflicted dependencies:
compile 'com.ibm.watson.developer_cloud:android-sdk:0.4.2'
compile 'com.ibm.watson.developer_cloud:java-sdk:3.9.1'
From the Watson Developer Cloud Java SDK documentation you can find the following:
The Android SDK utilizes the Java SDK while making some
Android-specific additions. This repository can be found here. It
depends on OkHttp and gson.
which is pointing to the first library. So, you should only use:
compile 'com.ibm.watson.developer_cloud:android-sdk:0.4.2'
I get an error when I try to use iText to generate a PDF at run time.
The error comes when the Application is run in device or geny Motion.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/lowagie/bc/asn1/ASN1Encodable.class.
My Gradle Code is :
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.visioneering.tfd"
minSdkVersion 15
targetSdkVersion 24
versionCode 5
versionName "1.5"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
android {
lintOptions {
checkReleaseBuilds false
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
compile 'com.github.florent37:materialtextfield:1.0.5'
compile 'com.android.support:cardview-v7:25.2.0'
compile 'com.android.support:support-v4:25.2.0'
compile 'com.google.android.gms:play-services:10.2.1'
compile 'com.fasterxml.jackson.core:jackson-databind:2.5.3'
compile 'com.googlecode.json-simple:json-simple:1.1'
compile 'com.weiwangcn.betterspinner:library-material:1.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.itextpdf:itext7-core:7.0.3'
compile 'com.itextpdf:itext-pdfa:5.5.11'
compile 'itext:itext:1.3.1'
compile 'org.xhtmlrenderer:flying-saucer-pdf-itext5:9.1.6'
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
Please help me to solve this problem.
duplicate entry: com/lowagie/bc/asn1/ASN1Encodable.class - that points to iText 2.1.7 or older, which is not known to be compatible with Android.
There are a couple of things wrong in your Gradle file:
compile 'com.itextpdf:itext-pdfa:5.5.11' - that points to the PDF/A add-on of iText 5, version 5.5.11, which is compatible with Android, but you still need the Android port of iText 5, which is called iTextG. So you need to add compile 'com.itextpdf:itextg:5.5.10'. Yes, 5.5.10, not 5.5.11, because there is no itextg:5.5.11. See http://repo1.maven.org/maven2/com/itextpdf/itextg/
I am guessing that you think the "a" in "pdfa" means Android, but it doesn't. It stands for PDF/A: the PDF spec for archiving (ISO 19005), see https://en.wikipedia.org/wiki/PDF/A. If you don't need archiving (you probably don't, in a typical Android app), so you probably need to remove compile 'com.itextpdf:itext-pdfa:5.5.11'
compile 'com.itextpdf:itext7-core:7.0.3' - this is iText 7, which is not compatible with Android. Remove that line.
compile 'itext:itext:1.3.1' - is an ANCIENT version of iText, and is probably what is causing your error. Remove that line.
compile 'org.xhtmlrenderer:flying-saucer-pdf-itext5:9.1.6' - this is something special, which I don't know enough about. It may or may not pull in another dependency of iText, which may or may not be the wrong version. Tag your question with flying-saucer to attract extra attention.
I want to use some Google services in my application, so I have added this line to the .gradle file: com.google.android.gms:play-services-gcm:8.7+. But after trying to sync the project I got this error:
Failed to resolve: com.google.android.gms:play-services-gcm:8.7+
I checked all the available answers on Stackoverflow. They suggest installing the sdk for Google repository and Google play services and I did that. Here is a screenshot of the sdks installed on my computer:
Here is the gradle file code:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.project.android.eyedetection"
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/localization/LocalizedFormats_fr.properties'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
compile project(':libraries:opencv')
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.google.android.gms:play-services:8.7+'
compile files ('libs/commons-math-2.2.jar')
compile files ('libs/commons-math-2.2-javadoc.jar')
compile files ('libs/commons-math-2.2-sources.jar')
}
I tried to remove the +, but that didn't solve it.
How can I solve the problem?
EDIT: As suggested by Stanojkovic and Gabriele Mariotti using 8.4 solves the problem, this is because I was mistakenly trying to use 8.7 which is not released yet. Thanks all.
Try with
com.google.android.gms:play-services-panorama:8.4.0
Your issue depends by
compile 'com.google.android.gms:play-services:8.7+'
This version is not published yet (the apk is still in rollout, but the library is not public in the IDE)
Use the last stable release:
compile 'com.google.android.gms:play-services:8.4.0'
I am working on one android application, where i am using two libraries ( Aviary android sdk and PrintIO sdk)
Getting conflict in libraries and getting this error each time when compiling project :
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: it/sephiroth/android/library/widget/AbsHListView$1.class
I have not used such library anywhere in my project as well as i also checked in both libraries, but not found anything.
Please anyone suggest me anything why i am getting this conflict in my project?
EDIT :
Here is my build.gradle file :
apply plugin: 'com.android.application'
repositories {
mavenCentral()
jcenter()
mavenLocal()
maven {
name 'maven.aviary.com'
url uri("http://maven.aviary.com/repo/release")
}
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
lintOptions {
disable 'MissingTranslation'
}
defaultConfig {
applicationId "XXXXX.XXXXX"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
renderscriptTargetApi 18
renderscriptSupportModeEnabled true
multiDexEnabled true
}
packagingOptions {
exclude 'lib/armeabi-v7a/librsjni.so'
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/httpclient-4.0.1.jar')
compile files('libs/httpcore-4.0.1.jar')
compile project(':MaterialDialog')
compile files('libs/universal-image-loader-1.9.1.jar')
compile project(':StaggeredGrid')
compile project(':CustomFloatingButtonLibrary')
compile files('libs/dropbox-android-sdk.jar')
compile files('libs/gcm.jar')
compile project(':image_select_lib')
compile files('libs/json-simple-1.1.1.jar')
compile project(':chipsLib')
compile files('libs/aws-android-sdk-1.4.3-s3.jar')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.instabug.library:instabugsupport:1.+'
// compile 'com.aviary.android.feather.sdk:aviary-sdk:3.6.3'
compile 'com.yalantis:phoenix:1.2.3'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.google.android.gms:play-services-location:7.5.0'
compile project(':Aviary-SDK')
compile project(':SwipyLib')
compile project(':printio')
}
EDIT 2 :
I searched for library (AbsHListView) using CTRL + N and it result in following :
I did a google search for the class it/sephiroth/android/library/widget/AbsHListView$1.class and found out it is used by the library here.
Looks like one of your dependencies is using this library. If you are on Windows press CTRL + N and enter this AbsHListView and search. You will find the conflicting class.
EDIT:
Change your dependency like this:
compile project(':printio') {
exclude group: 'it.sephiroth.android.library.widget'
}
I am using httpmime and httpcore in my project and I am getting this warning
Warning:Dependency org.apache.httpcomponents:httpclient:4.4.1 is
ignored for debug as it may be conflicting with the internal version
provided by Android.
Warning:Dependency org.apache.httpcomponents:httpclient:4.4.1 is
ignored for debug as it may be conflicting with the internal version
provided by Android.
my dependencies look like this
dependencies {
compile files('libs/gson-2.2.2.jar')
compile files('libs/classes.jar')
compile files('libs/gcm.jar')
compile files('libs/splunk-mint-4.2.jar')
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpmime:4.4.1'}
As suggested in other places I added this to my build.gradle file
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'}
Any idea how to solve this issue?
Firstly remove the lines
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpmime:4.4.1'
then at their place add the lines in build.gradle given by:
compile ('org.apache.httpcomponents:httpmime:4.3'){
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'commons-io:commons-io:1.3.2'
You can try this if your compileSdkVersion is 19(IN MY CASE) more preferably. Hope this will resolve the issue...
Use repacked version of the apache http client suitable for android
dependencies {
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
}
https://hc.apache.org/httpcomponents-client-4.3.x/android-port.html
Solution 1
I know this is so late but i'm posting here because accepted answer was not working for me
previously i used
dependencies {
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'org.apache.httpcomponents:httpmime:4.3.3'
compile 'org.apache.httpcomponents:httpcore:4.3.2'
compile files('libs/httpclient-4.2.1.jar')
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
}
then i got the warning like question after that i commented some lines like bellow
dependencies {
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'org.apache.httpcomponents:httpmime:4.3.3'
//compile 'org.apache.httpcomponents:httpcore:4.3.2'
//compile files('libs/httpclient-4.2.1.jar')
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
}
now everything working fine
Edit
Solution 2
I got the best process than previous
add httpcore-4.3-beta1.jar and httpmime-4.3.jar in lib's folder and finally add
useLibrary 'org.apache.http.legacy' in your graddle file (Inside of android) as like bellow
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
//For http
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.app.videorotation"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
......
}
Solution:
add useLibrary 'org.apache.http.legacy'
configurations {
all*.exclude module: 'httpclient'
}
I think some people may need this,
This worked for me.
If you have kept the below one :-,
compile 'org.apache.httpcomponents:httpcore:4.4.4'
compile group: 'org.apache.httpcomponents' ,
name: 'httpclient-android' , version: '4.3.5.1'
change it to this,
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'