Unsupported Gradle DSL method found: 'exclude()' - android

If:
dependencies {
compile 'com.google.code.gson:gson:2.2.4'
compile 'de.keyboardsurfer.android.widget:crouton:1.8.3'
compile 'de.greenrobot:eventbus:2.2.0'
compile 'com.intellij:annotations:+#jar'
compile 'com.jpardogo.googleprogressbar:library:1.0.0'
compile project(':floatlabel')
compile project(':Android-SwipeToDismiss')
compile project(':Android-UndoBar') {
exclude group: 'com.nineoldandroids', module: 'library' // without or without this one
}
compile project(':AndroidSlidingUpPanel:library') {
exclude group: 'com.nineoldandroids', module: 'library' // without or without this one
}
}
I receive this error message:
Gradle 'mProject' project refresh failed: Build script error, unsupported Gradle DSL method found: 'exclude()'!
But this works:
dependencies {
compile 'com.google.code.gson:gson:2.2.4'
compile 'de.keyboardsurfer.android.widget:crouton:1.8.3'
compile 'de.greenrobot:eventbus:2.2.0'
compile 'com.intellij:annotations:+#jar'
compile 'com.jpardogo.googleprogressbar:library:1.0.0'
compile project(':floatlabel')
compile project(':Android-SwipeToDismiss')
compile project(':Android-UndoBar')
compile project(':AndroidSlidingUpPanel:library')
}
configurations {
all*.exclude group: 'com.nineoldandroids', module: 'library'
}
Trying to understand why, please clarify!

Use
compile (project(':Android-UndoBar')) {
exclude group: 'com.nineoldandroids', module: 'library' // without or without this one
}
So with extra parentheses.

Related

ZipException: duplicate entry: junit/extensions/ActiveTestSuite$1.class when running tests in firebase

I'm trying to run some tests into Firebase test lab platform and I'm finding a problem:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebugAndroidTest'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: junit/extensions/ActiveTestSuite$1.class
The tests works fine when I run them locally in a virtual device.
I'm working all day in this and I can't find a valid solution for me :(
Here's my dependencies:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// Dagger
// apt command comes from the android-apt plugin
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.appyvet:materialrangebar:1.3'
compile 'com.google.firebase:firebase-core:11.0.2'
compile 'com.google.android.gms:play-services-maps:11.0.2'
compile 'com.google.android.gms:play-services-location:11.0.2'
compile 'com.google.firebase:firebase-appindexing:11.0.2'
compile 'com.google.android.gms:play-services-analytics:11.0.2'
compile 'com.google.android.gms:play-services-gcm:11.0.2'
compile 'com.google.firebase:firebase-messaging:11.0.2'
compile 'com.google.firebase:firebase-config:11.0.2'
compile 'com.google.firebase:firebase-auth:11.0.2'
compile 'com.google.firebase:firebase-invites:11.0.2'
compile 'com.google.firebase:firebase-perf:11.0.2'
compile 'com.google.firebase:firebase-crash:11.0.2'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.7.5'
compile 'com.squareup.okhttp3:okhttp:3.3.1'
compile 'com.squareup.okio:okio:1.7.0'
compile 'info.guardianproject.netcipher:netcipher:1.2'
compile 'com.appsflyer:af-android-sdk:4.7.1'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.dagger:dagger:2.9'
testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:3.1.4'
testCompile 'org.robolectric:shadows-multidex:3.0'
testCompile 'org.mockito:mockito-core:1.10.19'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support:support-annotations:25.3.1'
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') {
exclude module: 'javax.annotation-api'
exclude module: 'support-annotations'
}
androidTestCompile ('com.android.support.test.uiautomator:uiautomator-v18:2.1.2') {
exclude module: 'javax.annotation-api'
exclude module: 'support-annotations'
}
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.2') {
// Necessary to avoid version conflicts
exclude module: 'support-v4'
exclude module: 'recyclerview-v7'
exclude module: 'appcompat-v7'
exclude module: 'support-annotations'
exclude module: 'design'
}
annotationProcessor 'com.google.dagger:dagger-compiler:2.9'
provided 'javax.annotation:jsr250-api:1.0'
Thank you very much
I'd start by determining which libraries are using a class with that name.
Android Studio you can use open file and type ActiveTestSuite. This will autocomplete with all the matching classes. For example, when I do this it seems to come from a junit class.
I'm not sure why you would only see this on Firebase. Possibly see if there's a flag to ensure the test build runs a clean operation before running.

TransformException: java.util.zip.ZipException: duplicate entry: com/activeandroid/ActiveAndroid.class

Please let me know what exactly require here, I can see same source is running fine in Android Studio Emulators but in third party emulators like bluestacks I can see following errors.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/activeandroid/ActiveAndroid.class
Please check my gradle dependencies here.
dependencies {
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
compile files('library/android-viewbadger.jar')
compile files('library/robobinding-0.8.1.jar')
compile files('library/activeandroid-3.1-SNAPSHOT.jar')
compile project(':Android-Validator')
// compile files('library/java-rt-jar-stubs-1.5.0.jar')
}
dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:25.0.1'
compile ('com.android.support:appcompat-v7:25.0.1'){
exclude module: 'support-v4'
}
compile 'com.viewpagerindicator:library:2.4.1#aar'
compile 'com.f2prateek.progressbutton:progressbutton:2.1.0#aar'
compile files('library/afreechart-0.0.4.jar')
compile 'commons-io:commons-io:+'
compile 'com.google.code.gson:gson:2.2.+'
compile 'com.google.guava:guava:16+'
compile 'joda-time:joda-time:2.9.4'
compile 'org.apache.commons:commons-collections4:4.1'
compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
compile 'com.sun.codemodel:codemodel:2.4.1'
compile 'org.apache.httpcomponents:httpmime:4.5.1'
compile 'ch.acra:acra:4.9.0'
compile 'org.jsoup:jsoup:1.10.2'
compile 'org.apache.commons:commons-lang3:3.4'
compile ('org.simpleframework:simple-xml:2.7.1'){
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
compile files('library/pdfjet-5.75.jar')
compile 'log4j:log4j:1.2.17'
compile 'com.splunk:mint-android-sdk:5.2.1'
compile 'de.mindpipe.android:android-logging-log4j:1.0.3'
compile files('library/ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar')
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
}
This issue usually came when the same class is added in gradle twice.
Why you are using
compile files('library/activeandroid-3.1-SNAPSHOT.jar')
and
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
This is the reason for this.Try adding it once only and then build the gradle and run

Getting duplicate resource error in gradle android

I m adding google maps and firebase messaging in my android app but after building the error as duplicate resource.
My log cat error is
Error:Execution failed for task ':app:mergeDebugResources'.
> [string/google_api_key] F:\Android Workspace\FoxindTracker\app\src\main\res\values\strings.xml [string/google_api_key] F:\Android Workspace\FoxindTracker\app\build\generated\res\google-services\debug\values\values.xml: Error: Duplicate resources
My compile dependency are as follows
compile 'com.android.support:appcompat-v7:24.+'
compile 'com.android.support:design:24.+'
//compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.google.android.gms:play-services-maps:9.0.0'
compile 'com.google.firebase:firebase-messaging:9.0.0'
compile 'com.android.support:cardview-v7:24.+'
compile 'com.android.support:recyclerview-v7:24.+'
compile 'org.igniterealtime.smack:smack-android:4.1.4'
compile 'org.igniterealtime.smack:smack-tcp:4.1.4'
compile 'org.igniterealtime.smack:smack-im:4.1.4'
compile 'org.igniterealtime.smack:smack-extensions:4.1.4'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.github.siyamed:android-shape-imageview:0.9.+#aar'
// compile 'com.squareup.retrofit2:converter-simplexml:2.1.0'
compile ('com.squareup.retrofit2:converter-simplexml:2.1.0') {
exclude group: 'xpp3', module: 'xpp3'
exclude group: 'stax', module: 'stax-api'
exclude group: 'stax', module: 'stax'
}
compile('com.digits.sdk.android:digits:1.10.3#aar') {
transitive = true;
}
compile "commons-io:commons-io:+"
compile 'com.squareup.picasso:picasso:2.5.2'
}
apply plugin: 'com.google.gms.google-services'
Please help me where am i wrong
I will suggest to check your string.xml have duplicate or same string you have decalred double. So you can check once your all string resources
As per your log error
google_api_key
Is duplicate String. I hope it will work.
Just rename google_api_key to something like g_api_key. Firebase name it as google_api_key so it shows duplicate. I hope this helps.

Gradle dependency exclusion not working

My project build.gradle dependencies are:
dependencies {
...
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-appinvite:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'co.realtime:messaging-android:2.1.58'
}
And the co.realtime:messageing-android build.gradle dependencies are:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile ('com.android.support:appcompat-v7:21.0.3'){
transitive = true;
}
compile ('com.google.android.gms:play-services:6.1.71'){
transitive = true;
}
compile ('com.googlecode.json-simple:json-simple:1.1'){
transitive = true;
}
}
If I try to compile my project I get the following error:
Error:Gradle: Execution failed for task
':app-module:processProdDebugResources'.
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
If I use enforceUniquePackageName(false) I get:
cannot resolve symbol to GoogleCloudMessaging.INSTANCE_ID_SCOPE
So I guess I'll have to solve this by managing the dependencies. I've tried:
compile ('co.realtime:messaging-android:2.1.58'){
exclude module: 'com.google'
}
compile ('co.realtime:messaging-android:2.1.58'){
exclude group: 'com.google.android.gms', module: 'play-services-gcm'
}
But nothing seams to work... How can I solve this?
Thanks.
The problem was in 'play-services-gcm' instead of 'play-services'
compile ('co.realtime:messaging-android:2.1.58'){
exclude group: 'com.google.android.gms', module: 'play-services'
}
grrr those typo mistakes... Well I thought I could delete this question but, once in a while someone has the same issue, so I will leave this here hoping perhaps it helps someone in need.

Execution failed for task ':app:packageAllLocalVersionDebugClassesForMultiDex'

Logcat Error:
Error:Execution failed for task ':app:packageAllLocalVersionDebugClassesForMultiDex'.>java.util.zip.ZipException: duplicate entry: bolts/AggregateException.class
App Gradle Dependency:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.jeremyfeinstein.slidingmenu:library:1.3#aar'
compile 'com.daimajia.swipelayout:library:1.1.8#aar'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services-appindexing:8.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.github.traex.rippleeffect:library:1.3'
compile 'com.facebook.fresco:fresco:0.9.0'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile project(':floating_button_library')
compile 'com.facebook.android:facebook-android-sdk:4.10.0'
}
After adding the dependency for Facebook SDK the build throws an Exception
suggest me an answer thanks..
EDIT:
SOLVED THE ERROR
Now they split bolts-android into bolts-applinks and bolts-tasks .so you need exclude both from the gradle build
compile ('com.facebook.android:facebook-android-sdk:4.10.0'){
exclude group: 'com.parse.bolts',
module: 'bolts-tasks'
exclude group: 'com.parse.bolts',
module: 'bolts-applinks';}
This works perfectly for me !!!!
there were two DIFFERENT versions of it conflicting. the facebooksdk
comes with bolts-android-1.1.x and appcompatv7 comes with 1.1.x.
so add below line,
compile ('com.facebook.android:facebook-android-sdk:4.10.0'){
exclude module: 'bolts-android'
exclude module: 'support-v4'
}

Categories

Resources