TransformException after moving to Android Studio

I tried to import the Eclipse Android working project into Android Studio. I am working on a Mac with the latest version of Android Studio. When I try to build, it keeps showing this error:

Error: execution completed for task ': Application: transformClassesWithJarMergingForDebug'.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: COM / Google / API / client / HTTP / AbstractHttpContent.class

The class that creates this problem is in the com.google.http-client: google-http-client-gson: 1.20.0 library in the com.google.api.client.http package. I tried a lot of things with the app.gradle file, for example, excluding the com.google.api.client.http group, but nothing works. Here is my app.gradle file:

apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.2" useLibrary 'org.apache.http.legacy' defaultConfig { applicationId "com.example.time2" minSdkVersion 17 targetSdkVersion 19 multiDexEnabled true } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } compileOptions.encoding = 'ISO-8859-1' } repositories { mavenCentral() } dependencies { compile 'com.android.support:support-v4:20.0.0' compile 'com.google.android.gms:play-services:+' compile 'com.google.http-client:google-http-client-gson:1.20.0' compile 'com.google.code.gson:gson:2.1' compile files('libs/commons-io-2.4.jar') compile files('libs/google-api-client-1.18.0-rc.jar') compile files('libs/google-api-client-android-1.18.0-rc.jar') compile files('libs/google-http-client-1.18.0-rc.jar') compile files('libs/google-http-client-android-1.18.0-rc.jar') compile files('libs/google-oauth-client-1.18.0-rc.jar') compile files('libs/httpcore-4.3.3.jar') compile files('libs/httpmime-4.3.6.jar') compile files('libs/json-simple-1.1.1.jar') compile files('libs/jsr305-1.3.9.jar') compile 'com.stripe:stripe-android:+' compile 'com.facebook.android:facebook-android-sdk:4.7.0' } 
+6
source share
2 answers

You do not have to manually add files to your project.

  Eg change
 compile files ('libs / commons-io-2.4.jar')
 compile files ('libs / google-api-client-1.18.0-rc.jar')
 compile files ('libs / google-api-client-android-1.18.0-rc.jar')
 compile files ('libs / google-http-client-1.18.0-rc.jar')
 compile files ('libs / google-http-client-android-1.18.0-rc.jar')
 compile files ('libs / google-oauth-client-1.18.0-rc.jar')
 compile files ('libs / httpcore-4.3.3.jar')
 compile files ('libs / httpmime-4.3.6.jar')
 compile files ('libs / json-simple-1.1.1.jar')
 compile files ('libs / jsr305-1.3.9.jar')

 to

 compile 'commons-io: commons-io: 2.4'
 compile 'com.google.api-client: google-api-client: 1.18.0-rc'
 compile 'com.google.api-client: google-api-client-android: 1.18.0-rc'
 compile 'com.google.http-client: google-http-client: 1.18.0-rc'
 compile 'com.google.http-client: google-http-client-android: 1.18.0-rc'
 compile 'com.google.oauth-client: google-oauth-client: 1.18.0-rc'
 compile 'org.apache.httpcomponents: httpcore: 4.3.3'
 compile 'org.apache.httpcomponents: httpmime: 4.3.6'
 compile 'com.googlecode.json-simple: json-simple: 1.1.1'
 compile 'com.google.code.findbugs: jsr305: 1.3.9'

Please make sure these are the correct packages. Let us know what you find after the update?

+3
source

The library 'com.google.http-client:google-http-client-gson:1.20.0' consists of the following nine modules:

 google-http-client google-http-client-android google-http-client-appengine google-http-client-xml google-http-client-protobuf google-http-client-jdo google-http-client-jackson google-http-client-jackson2 google-http-client-gson 

Some of these, for example, google-http-client , are turned on again depending on the tour as a jar . From here the recording is repeated.

Check this link for proper configuration when using google-http-java-client . It has step-by-step instructions - setup instructions

+2
source

All Articles