Android - transform Classes With Dex For Debug - android

My project was working fine until I added the Facebook dependency.
I've started getting this error.
I've read many question, the problem seems to be related to MultiDex.
But none of the solutions worked for me
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
'/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 1
Even after I remove what I've added, it still show and also gradle seems to be taking a lot of time while building than usual
Here is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "net.ciblo.spectrodraft"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
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'
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:cardview-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.daimajia.easing:library:1.0.1#aar'
compile 'com.daimajia.androidanimations:library:1.1.3#aar'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.pnikosis:materialish-progress:1.5'
compile 'com.nineoldandroids:library:2.4.+'
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
compile 'com.android.support:support-v4:23.2.1'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
}

Adding the following code to build.gradle app module solved my problem
android{
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
//...
compile 'com.android.support:multidex:1.0.0'
}

you can selectively compile Google Play service APIs into your app. For example, to include only the Google Fit and Android Wear APIs, replace the following line in your build.gradle file:
compile 'com.google.android.gms:play-services:8.4.0'
with these lines:
compile 'com.google.android.gms:play-services-fitness:8.4.0'
compile 'com.google.android.gms:play-services-wearable:8.4.0'
==> to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.

Adding the following in build.gradle fixed the issue for me,
android {
//...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
//...
}

This horrendous recurring issue hit me again recently. The gradle build stalls permanently at app:transformClassesWithDexForDebug, just running for hours and never completing. This time I fixed it by removing all references to 'fabric', a new layer of Crashlytics being pushed on us.
//apply plugin: 'io.fabric' //REMOVE
//classpath 'io.fabric.tools:gradle:1.26.1' //REMOVE

Related

Execution failed for task ':app:transformClassesWithMultidexlistForDebug' in Android Studio 2.3

I can build my project but can not run the app. When executing app it gives me error like
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.android.multidex.ClassReferenceListBuilder with arguments {/home/Git_Projects/Test1/app/build/intermediates/multi-dex/debug/componentClasses.jar /home/Git_Projects/Test1/app/build/intermediates/transforms/jarMerging/debug/jars/1/1f/combined.jar}
I tried to clean and rebuild project and Invalidate Catche and Restart. But, nothing helped me.
build.gradle (app)
apply plugin: 'com.android.application'
android {
dexOptions {
javaMaxHeapSize "4g"
}
compileSdkVersion 26
buildToolsVersion "26.0.1"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.app.test1"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled = true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
maven { url 'https://github.com/Kaustubh-Deshmukh/progressbar_repo/raw/master' }
maven { url 'https://dl.bintray.com/yazeed44/maven' }
}
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:multidex:1.0.1'
compile 'com.google.android.gms:play-services-gcm:10.0.1'
compile 'com.google.android.gms:play-services-places:10.0.1'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.google.android.gms:play-services-vision:10.0.1'
compile 'com.github.clans:fab:1.6.4'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.jakewharton:butterknife:8.4.0'
compile 'com.googlecode.libphonenumber:libphonenumber:7.1.1'
compile 'com.android.support:appcompat-v7:26.0.0'
compile 'com.android.support:design:26.0.0'
compile 'com.android.support:recyclerview-v7:26.0.0'
compile 'com.android.support:cardview-v7:26.0.0'
compile 'com.android.support:support-v4:26.0.0'
compile 'com.android.support:support-annotations:26.0.0'
compile 'com.android.support:percent:26.0.0'
compile 'com.android.support:support-v13:26.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.1'
compile 'com.facebook.fresco:fresco:1.5.0'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.kontaktio:sdk:3.3.2'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
testCompile 'junit:junit:4.12'
}
If I randomly remove some dependencies, then it executes fine. Does large app size creating problem to execute app ?
I am using android studio 2.3 and java-8-openjdk-amd64 and ubuntu 16.04
One strange thing : Everything was working correct before executing command
apt-get update
I am searching from days but nothing seems work.
As from your build.gradle file you have two versions for
compile 'com.android.support:support
Try using only one of the following:
compile 'com.android.support:support-v4:26.0.0'
compile 'com.android.support:support-v13:26.0.0'
Try to add below to build.gradle
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
Try to build by command line
gradle clean assembleDebug
After updating Android Studio from 2.3.0 to 3.0.1 , my problem solved.
Now, it works perfect.

While adding any new dependencies in android build.gradle file. it always show an error

Error:(42, 13) Failed to resolve: com.android.volley:volley:1.0.0
When add any dependencies in android build.gradle file it always shows the above error. But same project is running on a different machine same dependencies can add successful. I search lot for solving this problem but can't find any solution. Kindly Please help me to fix the problem Thank you.
I face the same error while adding any dependencies now, but few weeks before i can add any dependencies on my project
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "myappid"
minSdkVersion 17
targetSdkVersion 24
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
jcenter({url "http://jcenter.bintray.com/"})
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:design:24.0.0'
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
compile 'com.android.support:support-vector-drawable:24.0.0'
// VectorDrawableCompat
compile 'com.android.support:animated-vector-drawable:24.0.0'
compile 'com.android.support:support-annotations:24.0.0'
compile 'com.satsuware.lib:usefulviews:2.3.6'
compile 'com.github.ganfra:material-spinner:1.1.1'
compile 'com.google.android.gms:play-services-appindexing:8.1.0'
compile 'com.ramotion.foldingcell:folding-cell:1.0.1'
compile 'com.android.volley:volley:1.0.0'
}
I try many way to solve the problem i have faced but no one can rectify the problem. I ask the help of may experience developer, they told me that they never face such a problem in there life. So only solution i found is to reinstall android studio. Now it work perfectly. Any way thanks for your support.

Error:Cannot configure the 'publishing' extension after it has been accessed

Error:Cannot configure the 'publishing' extension after it has been accessed.
I am getting this error after updating my android studio.
this is my app.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
generatedDensities = []
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), proguard-rules.pro'
}
}
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/universal-image-loader-1.9.5.jar')
compile project(':databaseAutoCompleteLibrary')
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.android.support:support-v4:23.2.0'
compile 'com.android.support:gridlayout-v7:23.2.0'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.baoyz.swipemenulistview:library:1.3.0'
compile 'milyn:opencsv:1.6'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile project(':MPChartLib')
compile project(':filechooserlibrary')
//compile 'com.android.support:support-v4:18.0.0'
//compile 'com.android.support:appcompat-v7:18.0.+'
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:support-v13:23.2.0'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile project(':Volley')
compile 'com.google.android.gms:play-services:8.4.0'
}
please provide any solution.
I am using volley library.
Thanks.
I have faced the same issue after upgrading to latest studio.
I am not sure about the root cause but what I did is
comment below line from volley build.gradle
apply from: 'bintray.gradle'
As I can see there many project are there in you dependencies.
If possible comment same from all and try syncing again.
Same thing happened to me.
I am not a Gradle expert but my solution was a little bit less drastic. I just edited the bintray.gradle file by moving the line:
apply plugin: 'maven-publish'
just before the publishing action.
This problem seems to be related with this:
https://github.com/researchgate/gradle-release/issues/125
This error comes from volley module, I solved this problem by doing as follows:
open volley module, find bintray.gradle file and change
publishing {
publications {...}
}
to
publishing.publications {...}
then it will work just fine.
I got this now when I introduced a circular dependency among modules inadvertently, in case some one hits it in the future.

i integrated my app with google play services but in old versions before 5.X it crashes after updating google play service to 8.4.0

the app launches successfully in any version after 5.X but in old versions 4.X it crashes and give me this error :
java.lang.NoClassDefFoundError: com.google.android.gms.R$string
this is builde.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
defaultConfig {
applicationId "com.appsinnovate.hanorder"
// manifestPlaceholders =
[manifestApplicationId:"${applicationId}"]
manifestPlaceholders = [manifestApplicationId :
"${applicationId}",
onesignal_app_id
: "xxxxxxxxxxxx",
onesignal_google_project_number:"xxxxxxxxx"]
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
productFlavors {
}
useLibrary 'org.apache.http.legacy'
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':facebook')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:palette-v7:23.1.1'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.onesignal:OneSignal:1.+#aar'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.android.support:multidex:1.0.0'
}
apply plugin: 'com.google.gms.google-services'
build.gradle (application)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.google.gms:google-services:2.0.0-alpha6'
}
}
allprojects {
repositories {
jcenter()
}
}
You'll get this if you have not added the google play services library to your project correctly. Make sure you carefully follow the instructions at https://developers.google.com/android/guides/setup to add the library to your project. Then make sure you have all of your build tools and google repository packages up to date, as outline in my answer here: Could not find com.google.android.gms:play-services-analytics:8.1.0
Once you update all of this, it should work. I also noticed your google play package looks out of date. You have version 2.0.0. Current version should be 8.4.0 The line in your gradle should read compile 'com.google.android.gms:play-services:8.4.0'
Also, it looks like you have this in your Project gradle file. It should go in your MODULE gradle file instead.
UPDATE
You should change your gradle version to classpath 'com.android.tools.build:gradle:2.0.0-alpha6' I missed this on my original read through, but this should solve your issue.
i solved the problem by removing
compile 'com.google.android.gms:play-services:8.4.0'
because it need to use multiDexing because size exceeds 65K
so i removed from builde.gradle
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
......
multiDexEnabled true
......
compile 'com.android.support:multidex:1.0.0'
and i used libraries that i need
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'

com.android.build.transform.api.TransformException with android google play services

I'm trying to integrate Google Plus in my application, and it showing following error. below are exception and gradle
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.transform.api.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1
app build.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "xxx.com.xxxx"
multiDexEnabled true
minSdkVersion 15
targetSdkVersion 23
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:23.0.1'
//depend-materialcalendar
compile 'com.prolificinteractive:material-calendarview:0.8.1'
compile 'com.android.support:gridlayout-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.melnykov:floatingactionbutton:1.3.0'
//depend-cometchat
compile 'com.yalantis:contextmenu:1.0.4'
compile 'com.google.code.gson:gson:2.3'
compile files('libs/appcompat_v7.jar')
compile files('libs/cometchat-sdk.jar')
compile files('libs/jsoup-1.7.3.jar')
compile files('libs/picasso-2.5.2.jar')
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.google.android.gms:play-services-base:8.1.0'
compile 'com.google.android.gms:play-services-maps:8.1.0'
compile files('libs/volley.jar')
compile files('libs/PayPalAndroidSDK.jar')
compile files('libs/gcm.jar')
compile 'com.soundcloud.android:android-crop:1.0.1#aar'
compile 'com.facebook.android:facebook-android-sdk:4.6.0'
compile 'com.android.support:multidex:1.0.0'
compile 'com.google.android.gms:play-services-plus:8.1.0'
compile 'com.google.android.gms:play-services-identity:8.1.0'
}
project build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.google.gms:google-services:1.4.0-beta3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Try cleaning your project and then re-building.
Try adding multiDexEnabled true in your app build.gradle file.
defaultConfig {
multiDexEnabled true
}
I have added this on the Application class:
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
In my app build.grade file:
defaultConfig {
applicationId "com.example.android.exampleapp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
and added this as dependency:
compile 'com.android.support:multidex:1.0.0'
This solved my problem. Thanks
I just had the same problem in my current project when I moved the Android Gradle Plugin Version from 1.3.0 to 1.5.0.
The error was nearly the same one as the error of the OP except that java returned error code 2.
If finally turned out that I had the same jar file included in two different modules of the app.
Version 1.3.0 could handle this without problems, for version 1.5.0 I had to replace the jar files with a dependency for a separate module that contained a single copy of the jar file.
I have tried with adding
multiDexEnabled true
but did not work. then I have changed my build version from 23.0.2 to
buildToolsVersion "23.0.3"
then it works. hope it may help you.
try to add these line in your gradle
dexOptions {
javaMaxHeapSize "4g"
}

Categories

Resources