Gradle Failed: transformClassesWithDexForDebug with jdk 1.8 - android

All day I have a challenge with resolve update of some dependencies in my new project.
This is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "com...."
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.google.firebase:firebase-database:9.6.1'
compile 'com.google.firebase:firebase-storage:9.6.1'
compile 'com.firebaseui:firebase-ui:0.4.3'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.google.android.gms:play-services:9.6.1'
}
apply plugin: 'com.google.gms.google-services'
and error is:
Error:
"Execution failed for task: ':app:transformClassesWithDexForDebug'
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/home/bin/java" finished with non zero-exit value 2
The problem was showing when I tried to upload an image to Firebase storage. There was error with an internet connection etc. I decided to make update of libraries. After this there is an error with jdk 1.8.
Could somebody help me to resolve this challenge?
Regards

Basically you would also want to check and resolve version conflicts in your app's dependencies.
Also check if you have enabled multidex in your app.
I had a similar issue. In my app I am using guava-retrying library, which was fetching google guava library version 21. Guava version 21 requires JDK 1.8 without providing back porting support and this was causing this error in my case.
I was able to solve it by including the guava-retrying library so that it uses version 19.0 of guava library:
compile ("com.github.rholder:guava-retrying:2.0.0") {
exclude group: 'com.google.guava', module: 'guava'
}
compile 'com.google.guava:guava:19.0'

I believe you need to enable Multidex for your application.
add the Multidex library to your dependencies, then enable Multidex in defaultConfig.
Example:
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "com...."
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.google.firebase:firebase-database:9.6.1'
compile 'com.google.firebase:firebase-storage:9.6.1'
compile 'com.firebaseui:firebase-ui:0.4.3'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.google.android.gms:play-services:9.6.1'
compile 'com.android.support:multidex:1.0.0'
}
Then in `AndroidManifest.xml", enable Multidex installation:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
Source: https://developer.android.com/studio/build/multidex.html#mdex-gradle

Related

Error: Configuration with name 'default' not found in Android Studio, Volley and ArcMenu

I have an old volley configuration in my app. The app was built to target lollipop devices few years ago. I have also used an arcmenu library in same configuration like compile project('volley') and compile project('arcmenu').
Recently, I have reopened that project and tried running it again but it gives me this error:
Error: Configuration with name 'default' not found in Android Studio
I have installed all the previous platforms, from 21 to 26 in my sdk. Here's my gradle file
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "in.co.memoize"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
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'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services-gcm:7.5.0'
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.android.support:support-v4:22.2.0'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:cardview-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'org.apache.httpcomponents:httpcore:4.3.2'
compile 'org.apache.httpcomponents:httpmime:4.3.2'
compile 'com.getbase:floatingactionbutton:1.5.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'de.hdodenhof:circleimageview:1.2.2'
compile 'com.github.markushi:circlebutton:1.1'
compile 'it.neokree:MaterialTabs:0.11'
compile 'com.jpardogo.materialtabstrip:library:1.0.9'
compile 'com.pnikosis:materialish-progress:1.5'
compile 'com.navercorp.pulltorefresh:library:3.2.0#aar'
compile 'com.github.orangegangsters:swipy:1.2.0#aar'
compile 'com.android.volley:volley:1.1.0'
//compile project(':volley')
compile project(':arcmenu')
}
After installing the platform versions, I get this message:
Error:Unsupported method: BaseConfig.getApplicationIdSuffix().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.
My settings.gradle file:
//include ':app', ':volley' commented to triangulate which library was
causing the problem but still not fixed
include ':app'
include ':arcmenu'
and arc menu gradle file:
apply plugin: 'com.android.library'
android {
compileSdkVersion 19
buildToolsVersion "21.1.0"
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
Can anyone help me in resolving this issue? Thanks
I have fixed this by downloading and adding the dependencies as .aar/.jar files

All com.android.support libraries must use the exact same version specification gradle issue

I am getting the issue All com.android.support libraries must use the exact same version specification when I am trying to sync my gradle file. Can any one please tell me the way by which I can solve my problem. I have already gone through this solution All com.android.support libraries must use the exact same version specification. but unfortunately it is not working in my case. Below is my gradle.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.application"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
useLibrary 'org.apache.http.legacy'
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:recyclerview-v7:23.2.0'
compile 'org.altbeacon:android-beacon-library:2.+'
compile 'com.google.firebase:firebase-messaging:10.2.1'
compile 'com.google.android.gms:play-services-gcm:10.2.1'
compile 'com.google.code.gson:gson:2.7'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Since you are using
compile 'com.google.android.gms:play-services-gcm:10.2.1'
You have a dependency with the support libraries v24.
In general you can use this command to check your dependencies tree.
./gradlew app:dependencies

duplicate entry: com/google/android/gms/location/places/PlaceReport

i'm having a probleme when creating the APK
When i run the app, it works fine but when i build the apk it says
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/location/places/PlaceReport.class
gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.1'
useLibrary 'org.apache.http.legacy'
configurations {
}
defaultConfig {
applicationId "inc.exemple"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:design:25.1.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.baoyz.pullrefreshlayout:library:1.2.0'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
compile 'com.1gravity:android-rteditor:1.6.2'
compile 'com.github.irshulx:laser-native-editor:0.3.5'
compile 'com.github.arturogutierrez:badges:1.0.5#aar'
compile 'com.mikepenz:actionitembadge:3.3.1#aar'
compile 'com.mikepenz:iconics-core:2.8.1#aar'
compile 'com.mikepenz:fontawesome-typeface:4.7.0.0#aar'
compile 'com.synnapps:carouselview:0.0.10'
compile 'com.google.firebase:firebase-messaging:9.8.0'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
}
I believe i should exlude it, but i don't know how, please help, thank you.
So i had to create a new empty project and copy all the libs in it, and try one by one to find which one was containing the problem. the error was coming from the com.github.irshulx:laser-native-editor:0.3.5, it worked after i deleted it, then i modified the whole project and used another work around.

Android Studio - Unable to find optional library: org.apache.http.legacy

I am making an android app which features navigation drawer. I remember that I used some features that requires sdk version to be 24 so compileSdkVersion needs to be 24 as well as the targetSdkVersion, but my android phone is only 19 so I don't see the app downloaded on my phone, it is opened once I finished running the project but when I close the tab on my phone, I cannot open it again. So I tried to change the compileSdkVersion and targetSdkVersion to 19 but I'm having this error: Unable to find optional library: org.apache.http.legacy
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.marivel.cruz.threatmapping"
minSdkVersion 17
targetSdkVersion 19
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
signingConfigs {}
buildTypes {}
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
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:19.+'
compile 'com.android.support:support-v4:19.1.0'
compile 'com.google.android.gms:play-services-maps:9.8.0'
compile 'com.android.support:multidex:1.0.0'
compile 'com.google.android.gms:play-services:9.8.0'
testCompile 'junit:junit:4.12'
}
This might seem like a workaround, but try commenting out the use library line and add the following under dependencies in your gradle build file :
dependencies {
compile files('libs/httpclient-4.4.jar')
compile files('libs/httpcore-4.4.jar')
compile files('libs/httpmime-4.3.6.jar')
}
You will have to download those files from apache and add them to your libs directory. This has worked for me before, but as I said, it feels a bit like a workaround.
You can find those jar files here:
Httpclient
Httpcore
Httpmime

Uber SDK in android

I am trying to add an Uber 'request a ride' button in my android application. In my gradle build file I have added the following line:
compile 'com.uber.sdk:rides-android:0.5.0'
Automatically Android studio asks to sync the gradle files as they have changed. After this I get 500+ errors with my project but when I remove the dependency it all goes back to normal.
Could anyone please help me solve this issue?
The module gradle script:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
android {
useLibrary 'org.apache.http.legacy'
}
defaultConfig {
applicationId "com.example.android.myuberapp"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/fonts'] } }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile files('libs/android-async-http-1.4.4.jar')
compile files('libs/volley.jar')
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.github.sembozdemir:ViewPagerArrowIndicator:1.0.0'
compile 'com.google.maps.android:android-maps-utils:0.4+'
compile 'com.github.jakob-grabner:Circle-Progress-View:v1.2.9'
compile 'me.grantland:autofittextview:0.2.+'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.uber.sdk:rides-android:0.5.0'
}
The full set of errors:
Error file is here
It looks like you've past the 64k limit and should enable multidex.
The majority of those "errors" are actually warnings that gradle seems to be grouping together. Check the last couple lines of the error for the exact message.
In your build.gradle
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
And in your manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
Separately:
Since the Uber SDK isn't that large, another suggestion to delay multidex is to only the use the Play services libraries you actually need.
For example, instead of
'com.google.android.gms:play-services:8.4.0'
You could use just cloud messaging (if that is the component used).
com.google.android.gms:play-services-gcm:8.4.0
See more here

Categories

Resources