Gradle duplicate entries : build failed - java

I am running into this issue almost everytime when I add a new module to my app but this time I am not able to resolve it at all. I am sick and tired of not friendly messages and tools of gradle. Someone please help: If you need dependencies output too let me know - it's big :(
Error:
:app:transformClassesWithJarMergingForDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/appengine/tools/appstats/Inter
nalProtos$1.class
Here are 4 gradle files:
Top level gradle:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
classpath 'com.google.gms:google-services:1.5.0-beta2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
App gradle:
apply plugin: 'com.android.application'
apply plugin: 'hugo'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.app.myapp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
multiDexEnabled true
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
apply plugin: 'com.google.gms.google-services'
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/nineoldandroids-2.4.0.jar')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:gridlayout-v7:23.1.1'
compile 'com.android.support:mediarouter-v7:23.1.1'
compile 'com.android.support:palette-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:support-v13:23.1.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.mikhaellopez:circularimageview:2.1.1'
compile 'com.cocosw:bottomsheet:0.+#aar'
compile 'com.github.bumptech.glide:okhttp-integration:1.3.1'
compile 'com.google.android.gms:play-services-auth:8.3.0'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile project(path: ':backend', configuration: 'android-endpoints')
compile project(path: ':commons')
}
Backend gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.appengine:gradle-appengine-plugin:1.9.18'
}
}
repositories {
jcenter();
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.18'
compile 'com.google.appengine:appengine-endpoints:1.9.18'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.18'
compile 'javax.servlet:servlet-api:2.5'
compile 'com.ganyo:gcm-server:1.0.2'
compile project(path: ':commons')
}
appengine {
downloadSdk = true
appcfg {
oauth2 = true
}
endpoints {
getClientLibsOnBuild = true
getDiscoveryDocsOnBuild = true
}
}
Commons gradle:
apply plugin: 'java'
dependencies {
compile 'com.googlecode.objectify:objectify:4.0b3'
compile 'com.google.code.gson:gson:2.5'
}

you can try like this
compile 'com.android.support:multidex:1.0.1'
It might help you.

you can try this under
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
might help you

I removed compile project(path: ':commons') and it all worked. But I had to put same POJO in both app and backened. Putting them in common screwed up gradle. May be there is better way to share classes across app and backend.

Related

Android Sync issue with SDK versions

I am developing an Android application and I am using 'Firebase-Messaging' library in my application. Now I need to 'proguard' and unfortunatly, 'Firebase' generated errors. I searched for solution and then I change the 'buildToolVersion' version 25.0.0 into 26.0.2. When I changed the versions I got the below error. I tried lot of solutions from internet including the 'Firebase Github' itself, but no good. I am using 'Firebase-Messaging 12.0.1' and below is the error I get.
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute meta-data#android.support.VERSION#value value=(26.0.2) from [com.android.support:design:26.0.2] AndroidManifest.xml:28:13-35
is also present at [com.android.support:support-v4:26.1.0] AndroidManifest.xml:28:13-35 value=(26.1.0).
Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:26:9-28:38 to override.
build.gradle(Project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven { url 'https://maven.google.com' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(Module)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.sample.firebase"
minSdkVersion 18
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
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:design:26.0.2'
compile 'com.android.support:appcompat-v7:26.0.0'
compile 'com.jakewharton:butterknife:5.1.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'de.hdodenhof:circleimageview:2.2.0'
compile 'me.angrybyte.goose:goose:1.8.0'
compile 'com.flaviofaria:kenburnsview:1.0.7'
compile 'com.google.firebase:firebase-messaging:12.0.1'
compile 'com.google.firebase:firebase-core:12.0.1'
compile 'com.jpardogo.googleprogressbar:library:1.2.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
You need to change this line of code:
compile 'com.android.support:appcompat-v7:26.0.0'
with
compile 'com.android.support:appcompat-v7:26.0.2'
All dependencies must be the same version.

Error:(30, 18) Failed to resolve: com.android.support:design-v7:25.3.1

I have already add the "maven{url "https://maven.google.com"}" but it doesn't work
This is my build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://maven.google.com" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And this is my other build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.quizapp.conte.quizapp"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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'
})
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-database:10.2.0'
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.android.support:cardview-v7:25.3.1'
debugCompile 'com.android.support:design-v7:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-core:11.8.0'
}
apply plugin: 'com.google.gms.google-services'
Any ideas on what I'm doing wrong?
I tried everything and I do not know what to do.
I started the project recently so i didn't modify other files exept the build.gradle.
Thank you all.
Error:(30, 18) Failed to resolve: com.android.support:design-v7:25.3.1
It happens because this dependency doesn't exist.
Use
debugCompile 'com.android.support:design:25.3.1'
instead of
debugCompile 'com.android.support:design-v7:25.3.1'
In new Gradle version(4.1+), you must use google repository like below
allprojects {
repositories {
google()
}
}
If you're using a version of Gradle lower than 4.1, you must instead use
allprojects {
repositories {
maven {
url 'https://maven.google.com'
// An alternative URL is 'https://dl.google.com/dl/android/maven2/'
}
}

Error: cannot find symbol class/variable "TransportMediator"

i'm having an issue with my code when i try to run the app these errors shows up but i really don't know how to solve this all the dependencies Update tried to clean rebuild and validate chache but nothing happened here is the gradle file and the project gradle of the app any help is appreciated
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://jitpack.io'
}
maven {
url 'https://maven.google.com'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.amiapp.videodownloader"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
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:3.0.1', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile files('libs/glide-3.6.0.jar')
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:27.0.2'
compile 'com.google.android.gms:play-services-ads:11.8.0'
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.firebase:firebase-messaging:11.8.0'
compile 'com.google.firebase:firebase-crash:11.8.0'
compile 'com.android.support:cardview-v7:27.0.2'
compile 'com.android.support:recyclerview-v7:27.0.2'
compile 'com.github.turhanoz:reactivedirectorychooser:2.0.1'
compile 'com.timqi.sectorprogressview:library:2.0.1'
compile 'com.geniusforapp.fancydialog:FancyDialog:0.1.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Error:(10, 32) error: cannot find symbol class TransportMediator
Error:(98, 31) error: cannot find symbol variable TransportMediator
TransportMediator can be found in the v4 Support Library.
Include 'compile com.android.support:support-v4:27.0.2' in your module-level build.gradle file.

Java and Kotlin combined build error (Duplicate Zip Entry)

I have added Kotlin library to my existing project. After that I'm getting the build error. I commented all the recently added libraries and checked the main problem is after adding kotlin library
Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> java.io.IOException: Can't write [/home/imedrix-server/StudioProjects/kardioscreen-operatorapp/app/build/intermediates/multi-dex/debug/componentClasses.jar] (Can't read [/home/imedrix-server/StudioProjects/kardioscreen-operatorapp/app/build/intermediates/transforms/desugar/debug/76.jar(;;;;;;**.class)] (Duplicate zip entry [76.jar:org/intellij/lang/annotations/Flow.class]))
Project gradle
buildscript {
ext.kotlin_version = '1.2.21'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath ('com.google.firebase:firebase-plugins:1.0.5') {
exclude group: 'com.google.guava', module: 'guava-jdk5'
}
}
}
allprojects {
repositories {
google()
jcenter()
maven {url "https://maven.google.com"}
}
}
And the app gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-crash'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId 'com.example.android'
minSdkVersion 20
targetSdkVersion 27
versionCode 17
versionName "1.0"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
buildConfigField("String", "BASE_URL", "\"url\"")
buildConfigField("String", "API_KEY", "\"key\"")
}
}
productFlavors {
}
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude '.readme'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':controllers')
compile files('libs/achartengine-1.2.0.jar')
compile files('libs/dfuLibrary.jar')
compile 'com.android.support:appcompat-v7:27.0.2'
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
compile 'com.android.support:design:27.0.2'
compile 'com.android.support:recyclerview-v7:27.0.2'
compile 'com.android.support:cardview-v7:27.0.2'
compile 'com.polidea.rxandroidble:rxandroidble:1.0.2'
compile 'com.google.firebase:firebase-crash:11.8.0'
compile 'com.android.support.constraint:constraint-layout:1.1.0-beta4'
compile 'com.android.support:support-v4:27.0.2'
compile 'com.google.android.gms:play-services-location:11.8.0'
compile 'com.jakewharton:butterknife:8.8.1'
testCompile 'junit:junit:4.12'
/*compile 'org.hashids:hashids:1.0.3'
compile 'com.google.dagger:dagger:2.11'
compile 'javax.inject:javax.inject:1'
kapt 'com.google.dagger:dagger-compiler:2.11'
compile 'io.reactivex.rxjava2:rxjava:2.1.3'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
kapt 'com.jakewharton:butterknife-compiler:8.8.1'
compile 'com.amitshekhar.android:rx2-android-networking:1.0.0'
compile 'com.android.support:multidex:1.0.2'*/
}
apply plugin: 'com.google.gms.google-services'
If I remove the below line from the app gradle everything works fine. But if I add the kotlin library I'm getting the error.
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
How can I use the kotlin and Java together.
Atlast I found the answer, it was due to duplicate entry to annotation which can be solved by using the below lines in the gradle.
configurations {
compile.exclude group : 'org.jetbrains' , module : 'annotations'
}

Google GTM dependencies error

i use the GTM and have a question,please help me
app build.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.york.yorkbbs"
minSdkVersion 16
targetSdkVersion 25
versionCode 531
versionName "5.31"
multiDexEnabled true
ndk {
abiFilters "armeabi", "armeabi-v7a"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
dexOptions {
preDexLibraries = true
javaMaxHeapSize "4g"
}
lintOptions{
checkReleaseBuilds false
abortOnError false
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.1'
compile project(':library_googlemap')
compile project(':library_jcvideoplayer')
compile 'com.android.support:recyclerview-v7:25.3.0'
compile 'com.google.code.gson:gson:2.7'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.android.gms:play-services-tagmanager:10.2.1'
compile 'com.jakewharton:butterknife:8.0.1'
apt 'com.jakewharton:butterknife-compiler:8.0.1'
compile 'com.stripe:stripe-android:3.1.0'
compile 'com.paypal.sdk:paypal-android-sdk:2.15.3'//exclude group: 'com.squareup.okhttp3', module:'okhttp'
compile 'com.facebook.fresco:fresco:0.14.1'
compile 'com.facebook.fresco:animated-gif:0.14.1'
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.2.1'
compile 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:1.0.2'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.amazonaws:aws-android-sdk-s3:2.4.1'
compile project(':Qupaisdk-release')
compile 'com.google.code.findbugs:jsr305:3.0.0'
compile 'com.fasterxml.jackson.core:jackson-databind:2.6.4'
compile 'com.google.dagger:dagger-compiler:2.0.1'
compile 'com.google.dagger:dagger:2.0.1'
compile 'jp.wasabeef:blurry:2.1.1'
}
project build.gradle
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.3.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
allprojects {
repositories {
jcenter()
}
Error:Execution failed for task ':app:processDebugGoogleServices'.
Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 9.0.0.
thanks~
You should rectify your build.gradle
No Need
compile project(':library_googlemap') // Remove this line
Finally
compile 'com.google.android.gms:play-services-maps:10.2.1'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.android.gms:play-services-tagmanager:10.2.1'

Categories

Resources