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.
Related
I have followed the various links for this solution but nothing worked.
Below is the error:
java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
I have also enabled multidex and have added google services plugin at bottom of build.gradle file.Here is the build.gradle compiler dependencies:
compile fileTree(include: '*.jar', dir: 'libs')
compile files('libs/universal-image-loader-1.9.5.jar')
compile('com.crashlytics.sdk.android:crashlytics:2.6.8#aar') {
transitive = true;
}
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:mediarouter-v7:26.0.1'
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:recyclerview-v7:26.0.1'
compile 'com.android.support:support-v13:26.0.1'
compile 'com.daimajia.swipelayout:library:1.2.0#aar'
compile 'com.fasterxml.jackson.core:jackson-databind:2.5.+'
compile 'com.fasterxml.jackson.core:jackson-core:2.5.+'
compile('com.googlecode.json-simple:json-simple:1.1.1') {
exclude group: 'org.hamcrest', module: 'hamcrest-core'
}
compile 'com.google.firebase:firebase-messaging:11.4.0'
compile 'junit:junit:4.12'
compile 'com.nineoldandroids:library:2.4.0'
testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:3.1.2'
testCompile 'org.robolectric:shadows-multidex:3.1.2'
testCompile 'org.robolectric:shadows-httpclient:3.1.2'
testCompile 'org.robolectric:shadows-support-v4:3.1.2'
compile files('libs/beacon_sdk.jar')
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
compile('org.apache.httpcomponents:httpmime:4.3') {
exclude module: "httpclient"
}
compile 'com.google.android.gms:play-services:11.4.0'
compile 'com.google.firebase:firebase-core:11.4.0'
compile 'org.apmem.tools:layouts:1.10#aar'
compile 'org.apache.commons:commons-lang3:3.5'
compile 'com.android.support:cardview-v7:26.0.1'
Versions of the platform prior to Android 5.0 (API level 21) use the Dalvik runtime for executing app code. By default, Dalvik limits apps to a single classes.dex bytecode file per APK. In order to get around this limitation, you can add the multidex support library to your project:
Add following dependency
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 26
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<application
android:name="android.support.multidex.MultiDexApplication" >
...
</application>
</manifest>
if you do override the Application class but it's not possible to change the base class, then you can instead override the attachBaseContext() method and call MultiDex.install(this) to enable multidex:
public class MyApplication extends SomeOtherApplication {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
try this just
split google play services it will worked
use this
compile 'com.google.android.gms:play-services-analytics:11.4.0'
compile 'com.google.android.gms:play-services-drive:11.4.0'
compile 'com.google.android.gms:play-services-location:11.4.0'
compile 'com.google.android.gms:play-services-places:11.4.0'
compile 'com.google.android.gms:play-services-gcm:11.4.0'
compile 'com.google.android.gms:play-services-plus:11.4.0'
insted of this
compile 'com.google.android.gms:play-services:11.4.0'
I am using LeanCloud as my push notification service provider but somehow when I run my app it gives me this error. Below is my dependencies:
dependencies {
compile 'com.android.support:multidex:1.0.1'
compile project(':react-native-push-notification')
compile project(':react-native-svg')
compile project(':react-native-fbsdk')
compile project(':react-native-picker')
compile project(':react-native-maps')
compile project(':react-native-wechat')
compile project(':react-native-code-push')
compile fileTree(dir: "libs", include: ["*.jar"])
compile ("com.android.support:appcompat-v7:23.0.1")
compile ("com.facebook.react:react-native:+") // From node_modules
compile ('com.facebook.android:facebook-android-sdk:[4.22.1)')
compile ('cn.leancloud.android:avoscloud-sdk:v4.4.4')
compile ('cn.leancloud.android:avoscloud-push:v4.4.4#aar'){
transitive = true
}
}
The exact error message:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: okhttp3/internal/ws/RealWebSocket$1.class
I have tried to add "exclude group: 'com.squareup.okhttp3', module: 'okhttp'". It allows me to run the app but somehow I can't register my device on LeanCloud server.
I am stuck in this problem for so long. Thanks for any help or suggestions.
you can add this in your app.gradle
configurations.all {
// OkHttp 3.5.0+ includes the websockets API, so we need this to prevent a conflict
exclude module: 'okhttp-ws'
}
it may help you!
https://github.com/facebook/react-native/issues/12646
Add the below lines it may help you, working for me.
configurations.all { resolutionStrategy.force 'com.squareup.okhttp3:okhttp:3.4.1' }
When I'm building my project by "Run (applicaton)" build-in function - everything's fine, I can test my app through phone, but I want to create standalone application by gradle.
I'm using gradle :client:clean :client:assemble task, and that's my output:
Dex: Error converting bytecode to dex:sesWithDexForDebug
Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
By this link I've searched for some dependencies between my modules. I checked, that appcompat-v7 and design library have support-v4 library build-in, so I removed it from design library.
My build.gradle file:
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'
})
//Support Design
compile ('com.android.support:appcompat-v7:23.4.0')
compile ('com.android.support:design:23.4.0') {
exclude module: 'support-v4'
}
//Butter Knife
compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
//Retrofit
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
//JSON Utils
compile 'com.google.code.gson:gson:2.5'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
//Dagger 2
compile 'com.google.dagger:dagger:2.9'
annotationProcessor 'com.google.dagger:dagger-compiler:2.9'
provided 'javax.annotation:jsr250-api:1.0'
//Android Plot
compile 'com.github.PhilJay:MPAndroidChart:v3.0.1'
//Apache Commons
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
//RxJava
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'io.reactivex.rxjava2:rxjava:2.0.1'
//Tests
testCompile 'junit:junit:4.12'
}
How can I fix it?
Regards
EDIT
I added multiDexEnabled true, and it gaves me another error:
Error:Execution failed for task ':client:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/hardware/display/DisplayManagerCompat$JellybeanMr1Impl.class
When your app has over 64k methods, you must enable Multidex. Usually this happens when a large number of libraries are used.
To get around this, enable Multidex in your build.gradle
android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 25
multiDexEnabled true
}
...
}
Read more about Multidex here.
Just change this attribute
multiDexEnabled false to multiDexEnabled true
i have a project that uses Google Map API v2, and now i want to add GCM to this project, when i add GCM dependency to my gradle file i face with this error:
Error:Execution failed for task ':app:processDebugResources'.
Error: more than one library with package name 'com.google.android.gms'
You can temporarily disable this error with android.enforceUniquePackageName=false
However, this is temporary and will be enforced in 1.0
my dependencies are:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.github.rey5137:material:1.2.1'
compile ('com.google.android.gms:play-services:4.1.32')
compile 'com.google.android.gms:play-services-gcm:7.8.0'
compile 'com.jpardogo.materialtabstrip:library:1.1.0'
compile('com.balysv.materialmenu:material-menu:1.5.4') {
exclude group: 'com.nineoldandroids', module: 'library'
}
compile 'com.android.support:support-v4:22.2.0'
compile 'com.android.support:appcompat-v7:21.0.3'
}
what can i do?
compile ('com.google.android.gms:play-services:4.1.32')
compile 'com.google.android.gms:play-services-gcm:7.8.0'
Please DO NOT use two different version of Google Play Service.
Also, most importantly try using those gradle dependencies which required by your application instead of all dependencies. Check here
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