I am implementing multi dex for my project. I am able to compile the code afer implementing multidex but while running the project i am getting below mentioned error while executing packageAllDebugClassesForMultiDex task.
Error:Execution failed for task ':appname:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: android/support/multidex/MultiDex.class
dependencies list : -
dependencies {
compile project(':slidingMenu')
compile project(':androidPullToRefresh')
compile project(':googlePlayServices')
compile project(':caldroid')
compile files('libs/admsAppLibrary.jar')
compile files('libs/gson-2.3.1.jar')
compile files('libs/jackson-annotations-2.1.1.jar')
compile files('libs/jackson-core-2.1.1.jar')
compile files('libs/jackson-databind-2.1.1.jar')
compile files('libs/jsr305-1.3.9.jar')
compile files('libs/okhttp-2.2.0.jar')
compile files('libs/retrofit-1.9.0.jar')
compile files('libs/xtify-android-sdk-2.4.jar')
compile project(':clusterkraf')
compile files('libs/okio-1.0.0.jar')
compile files('libs/android-support-multidex.jar')
}
Below is my project structure.
library A contains my application class. In which i have implemented multidex.
Library B and library C depends on library A
My launch project D depends on library B and Library C. Library D android menifest i have defined the application class which is available in library A.
If you want to add play service library in build.gradle add compile 'com.google.android.gms:play-services:7.5.0' in dependences
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:7.5.0'
}
if there are conflict add
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
.....
dexOptions {
preDexLibraries = false
}
.....
}
in the android block
Related
I was using
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-appinvite:8.4.0'
in my application build.gradle and this in my project build.gradle
classpath 'com.google.gms:google-services:2.0.0-beta2'
From last 10 days i was getting crash because of GCM at the time of InstanceId.
So i found that we need to update GCM to latest gradle so i did the same
classpath 'com.google.gms:google-services:3.0.0'
and
compile 'com.google.android.gms:play-services-gcm:9.0.2'
compile 'com.google.android.gms:play-services-appinvite:9.0.2'
but now am getting Multidex error due to this. So i tried to resolve that too by following few steps like extending Application class with MultiDexApplication and all. Still getting the same issue.
My gradle dependencies
compile project(':aws-android-sdk-core-2.2.9')
compile project(':aws-android-sdk-s3-2.2.9')
compile project(':universal-image-loader-1.9.5')
compile project(':FlurryAnalytics-6.2.0')
compile project(':circularImageView')
compile project(':swipeMenuListView')
compile 'com.couchbase.lite:couchbase-lite-android:1.2.0'
compile 'com.instabug.library:instabugsupport:1.+'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-appinvite:8.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.dmytrodanylyk.android-process-button:library:1.0.4'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:multidex:1.0.1'
Any help will be appreciated!
In your build.gradle you may use this
compile 'com.google.android.gms:play-services:8.3.0'
So, remove it and use the needed API only,
Check the VicVu Answer in this link,
gradle - Android Studio build too slow multidex application
Have you tried adding the heap size adjustment to your build.gradle file? For example this will set the max heap size for dexing to 4GB, and it will also enable
multiDexEnabled option.
android {
...
dexOptions {
javaMaxHeapSize "4g"
}
defaultConfig {
multiDexEnabled true
}
}
I have added below dependency in my build.gradle file to implement GCM :
compile 'com.google.android.gms:play-services:7.8.0'
But, getting below error :
Error:Execution failed for task ':app:dexDebug'.
My builg.gradle file is as below :
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
//Dependency To hangle OKHTTP Operations
compile 'com.squareup.okhttp:okhttp:2.6.0'
//Dependency To Generate QRcode (Dependency to hangle QRcode libraries)
compile 'com.google.zxing:core:2.2'
compile 'com.embarkmobile:zxing-android-minimal:1.2.1#aar'
compile 'com.google.android.support:wearable:1.1.0'
//Dependency To hangle Scanning of QRCode
compile 'me.dm7.barcodescanner:zxing:1.8.3'
//Dependency To hangle Piccaso library
compile 'com.squareup.picasso:picasso:2.5.0'
//Multipart depency
// compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
compile('org.apache.httpcomponents:httpmime:4.3') {
exclude module: "httpclient"
}
compile 'com.android.support:cardview-v7:23.0.+'
//To make imageview round cornered
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.itextpdf:itextpdf:5.5.8'
compile 'com.google.android.gms:play-services:7.8.0'
}
Looking at the gradle file of your project I think you are facing issues with no of method constraint (which is 65536) imposed by the google.
You need to either remove unwanted library from your source code or you can create MultiDex file for your project.
To enabled multidex file do the following changes in your gradle file,
defaultConfig {
minSdkVersion 14
targetSdkVersion 14
// Enabling multidex support.
multiDexEnabled true
}
And create application class extending Application and put the following piece of code,
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
You can refer following link for more reference and information.
http://developer.android.com/tools/building/multidex.html
Hope this will help you to resolved your issue.
after adding Sugar ORM dependency to gradle script app file
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.github.satyan:sugar:1.4'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.google.android.gms:play-services-auth:8.4.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:design:23.1.1'
}
Gradle complied my project, but once I tried to run it in a physical device (via Android studio) I got this error :
Error:Your app has more methods references than can fit in a single dex file.
See https://developer.android.com/tools/building/multidex.html
There are now errors If I tried to compile and run the app with Sugar ORM 1.3
Has the library grown so large in version 1.4 it will no longer fit into a single DEX ?
Try to enable multiDex support by using:
defaultConfig {
multiDexEnabled true
}
in your build.gradle (app)
Hope this help!
I've tried any solution suggested trying to solved the aapt.exe error.
every time I'm trying to add a new dependency to the build.gradle I get this error and after removing the dependency the error disappear.
I've tried chnging the compile SDK, changing the build tools version, invalidate/clear cache, activating compile independent modules in parallel.
The only dependencies registered are:
signingConfigs { compile fileTree(include: '*.jar', dir: 'libs')
compile project(':android-support-v7-appcompat')
compile files('libs/android-integration-3.2.1.jar')
compile files('libs/android-core-3.2.1.jar')
How can I handle it if I need to add another dependency to my project?
I'm working on android studio 1.4.1
compileSdkVersion 19
buildToolsVersion '22.0.1'
you should be adding your dependency libraries in build.gradle in (Module:app), if you are adding any library using Android studio GUI it will end up adding that library in this place or if you manually place a library in libs and add it to project as library it will still be added here.
Kindly check where and how are you adding your dependency
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.google.code.gson:gson:2.4'
compile files('libs/commons-io-2.4.jar')
}
in above code gson library is added compile 'com.google.code.gson:gson:2.4' is added using android studio GUI and
apache common io is added compile files('libs/commons-io-2.4.jar')
by placing it's library in libs directory in the Android project
I'm trying to build my Android Studio project with gradle. I added a compile rule as follows:
compile 'com.google.android.gms:play-services:6.5.87'
However it gives the following error:
Error:Module version com.google.android.gms:play-services:6.5.87 depends on libraries but is not a library itself
I have tried changing version and excluding support-v4 module, as mentioned here:
Crouton depends on libraries but is not a library itself
But I cannot solve the error.
Any help would be appreciated.
EDIT: Here is my dependency list from my build.gradle file:
dependencies {
// compile project(':library')
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.android.support:recyclerview-v7:21.0.2'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
compile('org.apache.httpcomponents:httpmime:4.3.5') {
exclude module: 'org.apache.httpcomponents:httpclient'
}
}