1

I am trying to add microsoft azure mobile services to my existing android app. After adding the .jar files in my folder. I am getting error:

Execution failed for task ':app:transformClassesWithJarMergingForDebug.

For various file like annotation.class, Gson$5.class and as you can see in the error file it shows ApiJsonOperationCallback.class. I have tired a lot of things(such as ./gradlew clean and ./gradlew clean assemble) but have been running into deadends everywhere.

This is my gradle file

apply plugin: 'com.android.application'
android {compileSdkVersion 23
         buildToolsVersion "23.0.2"
defaultConfig {
    applicationId "com.example.jino.navigationplacepicker"
    minSdkVersion 17
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
defaultConfig {
    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
buildscript {
    repositories {
        jcenter()
       }
      }
    }
    dependencies {
         compile fileTree(include: ['*.jar'], dir: 'libs')
         testCompile 'junit:junit:4.12'
         compile 'com.android.support:appcompat-v7:23.2.1'
         compile 'com.android.support:design:23.2.1'
         compile 'com.google.android.gms:play-services:8.4.0'
         compile 'com.microsoft.azure:azure-mobile-services-android-sdk:2.0.3'
         compile files('libs/azuresdk-android-2.0.3/mobileservices/mobileservices-2.0.3-javadoc.jar')
         compile files('libs/azuresdk-android-2.0.3/mobileservices/mobileservices-2.0.3-sources.jar')
         compile files('libs/azuresdk-android-2.0.3/mobileservices/gson-2.2.2.jar')
         compile files('libs/azuresdk-android-2.0.3/mobileservices/guava-17.0.jar')
         compile files('libs/azuresdk-android-2.0.3/mobileservices/mobileservices-2.0.3.jar')
    }

And this is the error message

:app:compileDebugNdk UP-TO-DATE :app:compileDebugSources :app:transformClassesWithJarMergingForDebug FAILED Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/microsoft/windowsazure/mobileservices/ApiJsonOperationCallback.class :app:compileDebugJavaWithJavac Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Information:BUILD FAILED

Request you to please into this, and respond in layman terms as i am new to this.

Mihriban Minaz
  • 3,043
  • 2
  • 32
  • 52
  • If you are new to building with Gradle, then you may want to [read this post](http://stackoverflow.com/questions/36698816/gradle-what-is-a-non-zero-exit-value-and-how-do-i-fix-it/36698817#36698817), the additional notes section of my answer addresses your problem – OneCricketeer Apr 19 '16 at 20:20
  • Replace : compile files('libs/azuresdk-android-2.0.3/mobileservices/gson-2.2.2.jar') with compile files('libs/azuresdk-android-2.0.3/mobileservices/gson-2.2.2.jar'){ exclude module: 'gson' } – binaryKarmic Apr 21 '16 at 10:06
  • i tired that and this is the error that i got "Gradle sync failed: Gradle DSL method not found: 'exclude()' ". I did look for solutions for the problem but didnt find any.My gradle version is 1.5.0 @binaryKarmic – Jino Thomas Apr 21 '16 at 17:11

1 Answers1

1

The libraries are referenced twice in the gradle file causing them to conflict with each other.

The following lines are not needed.

compile files('libs/azuresdk-android-2.0.3/mobileservices/mobileservices-2.0.3-javadoc.jar')
compile files('libs/azuresdk-android-2.0.3/mobileservices/mobileservices-2.0.3-sources.jar')
compile files('libs/azuresdk-android-2.0.3/mobileservices/gson-2.2.2.jar')
compile files('libs/azuresdk-android-2.0.3/mobileservices/guava-17.0.jar')
compile files('libs/azuresdk-android-2.0.3/mobileservices/mobileservices-2.0.3.jar')

The following line will download and reference the needed binaries for Azure Mobile Services.

compile 'com.microsoft.azure:azure-mobile-services-android-sdk:2.0.3'

Here is a copy of a gradle file for a working Android application.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 20
    buildToolsVersion "19.1.0"

    defaultConfig {
        applicationId "com.example.yourapp"
        minSdkVersion 8
        targetSdkVersion 20
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    repositories {
        flatDir {
            dirs 'aars'
        }
    }
}

dependencies {
    compile 'com.google.code.gson:gson:2.3'
    compile 'com.google.guava:guava:18.0'
    compile 'com.microsoft.azure:azure-mobile-services-android-sdk:2.0.3'   
}
Naren
  • 847
  • 4
  • 7
  • i tried this, not when i run the code it builds but it gives a fatal error " java.lang.NoClassDefFoundError: com.google.gson.GsonBuilder". @Naren – Jino Thomas Apr 20 '16 at 07:18