I have the following gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/DEPENDENCIES'
}
defaultConfig {
applicationId "com.guesstheurf.guesstheurf"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile (
[group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.5.0'],
[group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.5.0'],
[group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.5.0']
)
compile ('org.apache.httpcomponents:fluent-hc:4.4.1')
}
When I build this, I get warnings stating
Dependency org.apache.httpcomponents:httpclient:4.4.1 is ignored for release as it may be conflicting with the internal version provided by Android.
This is a dependency relied on by httpcomponents:fluent-hc.
I found this source on dependency management(chapter 51.4.7: Excluding transitive dependencies) that indicates I can just exclude the transitive dependency that causes the conflict.
However when I change it to
compile ('org.apache.httpcomponents:fluent-hc:4.4.1') { exclude module: 'httpclient' }
the Gradle warning is indeed gone, but the problem still persists:
Caused by: java.lang.NoClassDefFoundError: org.apache.http.client.fluent.InternalEntityEnclosingHttpRequest
at org.apache.http.client.fluent.Request.Post(Request.java:95)
The issue stays when I use
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
as indicated in this answer.
When I use
configurations {
all*.exclude module: 'httpclient'
}
the warning is gone as well, though the runtime error persists.
This source which suggests to force my own version using force = true doesn't fix the issue either.
Explicitly adding the httpclient-related dependencies as suggested here doesn't work either (and doesn't remove the warnings):
compile 'org.apache.httpcomponents:httpclient:4.4.1'
compile 'org.apache.httpcomponents:fluent-hc:4.4.1'
compile "org.apache.httpcomponents:httpmime:4.4.1"
compile 'org.apache.httpcomponents:httpcore:4.4.1'
How can I get fluent-hc to work? And why doesn't it simply select the newest version of the httpclient package since that is the default resolution strategy according to 51.2.3 Resolve version conflicts?
And why doesn't it simply select the newest version of the httpclient
package since that is the default resolution strategy according
Because Android ships with an extremely outdated (pre-BETA1) version of HttpClient 4.0, which makes it impossible to use any version of stock HttpClient. Gradle plugin is apparently smart enough to warn you about incompatibility and possible conflicts.
You have two options here:
use official Android port of HttpClient, which is API compatible with the version shipped with Android by default
dependencies {
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
compile group: 'org.apache.httpcomponents' , name: 'fluent-hc' , version: '4.3.5'
}
Repackage HttpClient into a different name space using scripts developed by Dirk Boye. Your mileage with the latest releases of HttpClient may vary.
org.apache.http -> thank.you.google.org.apache.http
Seems like when building with Android Studio 1.4 for API 23, this line causes "Failed to resolve" error:
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
Use this instead:
compile group: 'cz.msebera.android' , name: 'httpclient', version: '4.4.1.1'
Download the jar here: http://mvnrepository.com/artifact/cz.msebera.android/httpclient/4.4.1.1
Related
Suddenly i got an error in the execution of the app.
I know that this qustion was already asked here: Annotation processors must be explicitly declared now
However the solution don't answer the problem :(
this is my build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 26
buildToolsVersion '27.0.0'
aaptOptions {
cruncherEnabled = true
}
defaultConfig {
applicationId "com.freelance.crdzbird_dev.clarobadge"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
renderscriptTargetApi 22
renderscriptSupportModeEnabled true
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
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 "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:26.+'
compile 'com.android.support:support-v4:26.+'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.github.javiersantos:MaterialStyledDialogs:2.1'
annotationProcessor 'com.google.auto.value:auto-value:1.1'
compile 'ai.api:libai:1.4.8'
compile 'ai.api:sdk:2.0.7#aar'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'io.mattcarroll.hover:hover:0.9.8'
compile 'com.gjiazhe:MultiChoicesCircleButton:1.0'
compile "org.apache.logging.log4j:log4j-core:2.8"
compile 'com.sackcentury:shinebutton:0.1.9'
compile 'com.yalantis:contextmenu:1.0.7'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
compile 'com.android.support:cardview-v7:26.0.0-alpha1'
compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'com.dlazaro66.qrcodereaderview:qrcodereaderview:2.0.2'
compile 'me.samthompson:bubble-actions:1.3.0'
compile 'com.google.android.gms:play-services:11.0.4'
compile 'com.github.apl-devs:appintro:v4.2.2'
compile 'com.github.PhilJay:MPAndroidChart:v3.0.2'
compile 'com.google.firebase:firebase-messaging:10.2.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
repositories {
mavenCentral()
Anyone knows how can this error be solved. I search in google without success.
This is the error that recieve
Error:Execution failed for task ':app:javaPreCompileDebug'.
> 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.
- log4j-core-2.8.jar (org.apache.logging.log4j:log4j-core:2.8)
Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future.
See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.
That user's error said this annotation processor was missing auto-value-1.1.jar (com.google.auto.value:auto-value:1.1), and the answer was to add:
annotationProcessor 'com.google.auto.value:auto-value:1.1'
Your error says log4j-core-2.8.jar (org.apache.logging.log4j:log4j-core:2.8) so you thought the answer was to add this?
annotationProcessor 'com.google.auto.value:auto-value:1.1'
You've copied it verbatim! Of course it won't work! Change the annotation processor to the one you're actually using.
Cough cough cough annotationProcessor 'org.apache.logging.log4j:log4j-core:2.8'
Please Add this to your build.gradle
testImplementation('org.robolectric:robolectric:4.3.1') {
// https://github.com/robolectric/robolectric/issues/5245
exclude group: 'com.google.auto.service', module: 'auto-service'
}
Like this
After that clean Project and Build
Hope it Helps
I am trying to use opencsv library jar file but while importing i am getting the error message saying "Fail to load plugin descriptor from file *.jar".
I checked for META-INF/plugin.xml file inside the jar, but there is none.
So, i am now importing the source code of opencsv. I am getting error with java 7 api used within the library source code. All the usages of 'java.bean.*' package is giving 'cannot find symbol' error.
Following is the build.gradle file content:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.amadeus.jbisht.mytestproject"
minSdkVersion 23
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
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.1', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.+'
testCompile 'junit:junit:4.12'
}
Please let me know what am I missing here. I can see it listed under 'External Libraries' but android studio isnt picking it up.
Gradle dependencies are the way to go:
compile group: 'com.opencsv', name: 'opencsv', version: '3.8+'
E.g.,
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile group: 'com.opencsv', name: 'opencsv', version: '3.8+'
}
Gradle will automatically import the required files and integrate the library.
opencsv need some java.bean libraries, but they are not included in the Android SDK.
To resolve this :
download sources of opencsv
download openbean
include both in your Android Studio project
replace java.bean.* dependancies by localpath.bean.* in opencsv sources
I know there are similar questions on the same error that I'm getting but none of them actually worked for me. The problem is when I try to use GsonConverterFactory with my Retrofit client, it gives me this error.
Error:Execution failed for task ':client:transformClassesWithJarMergingForOCStagingDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/gson/annotations/Expose.class
There is indeed a solution which actually suggests me to remove the gson module from the com.squareup.retrofit2:converter-gson:2.1.0 library in following way-
compile ('com.squareup.retrofit2:converter-gson:2.1.0') {
exclude group: 'com.google.code.gson.annotations', module: 'annotations'
}
But if I do this, then the GsonCoverter stops working and all network requests are failing.
I'm adding the details of all my dependencies in below.
dependencies {
// Using sfl4j allows us to replace different loggers later, if desired
compile 'org.slf4j:slf4j-api:1.7.21'
compile project(':adyen')
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-v4:22.0.0'
compile 'com.android.support:appcompat-v7:22.0.+'
compile 'com.google.code.findbugs:jsr305:3.0.0'
compile 'com.fasterxml.jackson.core:jackson-databind:2.1.1'
compile('com.miairline:domain:5.1.19') {
exclude group: 'org.slf4j'
exclude group: 'log4j'
exclude group: 'commons-logging'
exclude group: 'org.apache.httpcomponents'
}
compile 'android.tools.support:annotations:20.0.1'
compile 'com.alexgilleran:icesoap:1.0.2'
compile 'commons-validator:commons-validator:1.4.0'
compile 'org.apache.commons:commons-lang3:3.0'
compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.7'
compile 'com.samskivert:jmustache:1.10'
compile 'org.alljoyn.bus:alljoyn-android:15.04.00a'
compile 'com.radaee.pdfex:com-radaee-pdfex:2.6.2'
compile 'com.adyen.services:android-lib:1.10p7'
compile 'net.christophersnow:sync-android-p2p:0.0.6-RC3'
compile('com.crashlytics.sdk.android:crashlytics:2.6.5#aar') {
transitive = true
}
compile 'com.iecisa:mposplugin_production:1.25#aar'
compile('org.restlet.jse:org.restlet:2.1-M7') {
exclude group: 'org.osgi', module: 'org.osgi.core'
}
compile 'org.restlet.jse:org.restlet.ext.simple:2.1-M7'
testCompile('junit:junit:4.10',
'org.slf4j:slf4j-simple:1.7.21',
'org.hamcrest:hamcrest-integration:1.3',
'com.miairline.test.uiautomator:uiautomator:18',
'org.robolectric:robolectric:2.0',
'org.powermock:powermock-api-mockito:1.5.1',
'org.powermock:powermock-core:1.5.1',
'org.powermock:powermock-api-easymock:1.5.1',
'com.github.rtyley:android-screenshot-celebrity:1.9')
compile 'com.akexorcist:RoundCornerProgressBar:2.0.3'
compile 'com.github.bmarrdev:android-DecoView-charting:v0.9.6'
compile ('com.squareup.retrofit2:retrofit:2.1.0') {
exclude group: 'com.google.code.gson', module: 'gson'
}
compile ('com.squareup.retrofit2:converter-gson:2.1.0') {
exclude group: 'com.google.code.gson.annotations', module: 'annotations'
}
compile('io.socket:socket.io-client:0.8.2') {
// excluding org.json which is provided by Android
exclude group: 'org.json', module: 'json'
}
compile('com.github.bright:slf4android:0.1.3') {
transitive = true
}
}
I've also tried looking into the dependency tree and found nothing duplicate over there. The strange thing is, it's working for other project and not in this. Also attaching the defautlConfig for my build.gradle
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
multiDexEnabled true
}
So i recently switched my Android Studio default JDK to Java 8, so I could use Lambda expressions. I had to enable Jack to let the gradle build, but now when I try to rebuild my applicaiton, I am getting about 3 different errors that seem to be coming from Jack. I can't seem to find the root of any of these problems, and would like to stay building with J8. Any insight or help for this is much appreciated. Here are the errors I am getting during build:
1)
Error:Library reading phase: Type javax.inject.Named from file
'C:\Users\nicholas\AndroidStudioProjects\BaseIntegrations\app\build\intermediates\jill\debug\packaged\javax.inject-2.4.0-b10-e2682135301b663484690f1d3a4a523bcea2a732.jar'
has already been imported from file
'C:\Users\nicholas\AndroidStudioProjects\BaseIntegrations\app\build\intermediates\jill\debug\packaged\javax.inject-1-4a242883e90a864db3b80da68e11a844f842d2df.jar',
type 'javax.inject.Named' (see property 'jack.import.type.policy' for
type collision policy)
2)
Error:com.android.jack.JackAbortException: Library reading phase: Type
javax.inject.Named from file
'C:\Users\nicholas\AndroidStudioProjects\BaseIntegrations\app\build\intermediates\jill\debug\packaged\javax.inject-2.4.0-b10-e2682135301b663484690f1d3a4a523bcea2a732.jar'
has already been imported from file
'C:\Users\nicholas\AndroidStudioProjects\BaseIntegrations\app\build\intermediates\jill\debug\packaged\javax.inject-1-4a242883e90a864db3b80da68e11a844f842d2df.jar',
type 'javax.inject.Named' (see property 'jack.import.type.policy' for
type collision policy)
3)
Error:com.android.jack.backend.jayce.TypeImportConflictException: Type
javax.inject.Named from file
'C:\Users\nicholas\AndroidStudioProjects\BaseIntegrations\app\build\intermediates\jill\debug\packaged\javax.inject-2.4.0-b10-e2682135301b663484690f1d3a4a523bcea2a732.jar'
has already been imported from file
'C:\Users\nicholas\AndroidStudioProjects\BaseIntegrations\app\build\intermediates\jill\debug\packaged\javax.inject-1-4a242883e90a864db3b80da68e11a844f842d2df.jar',
type 'javax.inject.Named' (see property 'jack.import.type.policy' for
type collision policy)
4)
:app:compileDebugJavaWithJack FAILED
Error:Execution failed for task ':app:compileDebugJavaWithJack'.
java.io.IOException: com.android.jack.api.v01.CompilationException: Library reading phase: Type javax.inject.Named from file 'C:\Users\nicholas\AndroidStudioProjects\BaseIntegrations\app\build\intermediates\jill\debug\packaged\javax.inject-2.4.0-b10-e2682135301b663484690f1d3a4a523bcea2a732.jar' has already been imported from file 'C:\Users\nicholas\AndroidStudioProjects\BaseIntegrations\app\build\intermediates\jill\debug\packaged\javax.inject-1-4a242883e90a864db3b80da68e11a844f842d2df.jar', type 'javax.inject.Named' (see property 'jack.import.type.policy' for type collision policy)
Here is the app level build.gradle:
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.nicholas.baseintegrations"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
jackOptions {
enabled true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
useLibrary 'org.apache.http.legacy'
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.google.android.gms:play-services-gcm:9.4.0'
compile project(path: ':backend', configuration: 'android-endpoints')
compile "com.getbase:basecrm-java:1.4.3"
compile 'com.android.support:recyclerview-v7:24.2.0'
compile 'com.android.support:palette-v7:24.2.0'
compile 'com.android.support:cardview-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.21'
compile group: 'org.glassfish.jersey.media', name: 'project', version: '2.23.2', ext: 'pom'
}
All help is very appreciated, as I know this is a new things, but cannot seem to find questions regarding the Jack/J8 build process. Thanks in advance.
We're looking into this, I think it's due to different behavior of the Android Gradle plugin for Jack and javac. As a workaround, you can try this in jackOptions
additionalParameters = [ "jack.import.type.policy" : "keep-first" ]
But be aware that with that option, Jack will keep the first definition of the class it encounters.
You can track our progress here: https://code.google.com/p/android/issues/detail?id=222273
I ended up solving this build issue. One of my dependencies was adding a second javax.inject library which was throwing these build errors saying that the javax.inject jar had already been imported from a previous one.
So I had javax.inject-1 and javax.inject-2.4.0-b10. I ended up excluding the javax.inject module from one of my dependencies and it cleared up issues with the build and is working jsut fine now.
Here is the dependencies section of my app build.gradle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile project(path: ':backend', configuration: 'android-endpoints')
compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.21'
compile (group: 'org.glassfish.jersey.media', name: 'project', version: '2.23.2', ext: 'pom')
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.google.android.gms:play-services-gcm:9.4.0'
compile ('com.getbase:basecrm-java:1.4.3') {
exclude (group: 'javax.inject', module: 'javax.inject')
}
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:palette-v7:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
}
And you can see the group exclusion in the basecrm dependency. So if anyone else has this issue just watch out for duplicate External Libraries coming from some dependency import.
I met the same problem,Then I found a same package in these two jar,But them are not a same version.
So modify to them have a same version.
My friend Gave me a project which was built in Windows platform and I have ubuntu. So when I import the project I am getting this error,
Error:(1, 0) Cause: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0
How can get my project running. I have tried all the possible solutions but didn't work any one of them.
I have already point my SDK path and using JDK 1.7.0. Using Gradle 2.14.1 which is latest one.
Here is my gradle.build file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.example.lenovo.myapp"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.api-client:google-' +
'api-client-gson:+'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.google.http-client:google-http-client-android:+'
compile 'com.google.api-client:google-api-client-android:+'
compile 'com.google.code.gson:gson:2.2.4'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'com.google.android.gms:play-services-identity:9.2.1'
compile 'com.google.android.gms:play-services-plus:9.2.1'
compile 'com.google.android.gms:play-services-gcm:9.2.1'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpmime:4.3.6'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha5'
compile 'com.github.bumptech.glide:glide:3.6.0'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.1.3'
testCompile 'junit:junit:4.12'
}
Any solution would be appreciated. I am stuck since last 2 days.
I have already point my SDK path and using JDK 1.7.0
You need JDK 1.8 with the new version of Studio and the build tools.
You are trying to use JDK 1.7. The project was built on 1.8 ( 52.0 - refer this link How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version). So, probaby using 1.8 JDK and JRE may work for you.