Today I migrated to Android Studio 1.1 and started to update the version of some libraries. When I build the project using the gradle button everything seems work properly but when I try to run the application I read in the gradle console output the error message that you can see at the end of the post. For the error message is clear for me that some libraries are using internally some libraries that are common between my dependencies and they have likely different versions. Someone knows how can I discover what are the libraries in conflict and how can I fix that issue (I can not remove any library from the project). Below you can find an abstraction of the build files in my project. Thanks in advance :)
Project's gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
app's (main module) gradle file
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
applicationId 'com.myapp'
minSdkVersion 16
targetSdkVersion 19
versionCode 1
versionName '1.0.0'
}
buildTypes {
debug {
debuggable true
}
release {
debuggable false
}
}
dexOptions {
preDexLibraries = false
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
dependencies {
compile project(':facebook')
compile 'com.crashlytics.android:crashlytics:1.+'
compile 'com.jakewharton:butterknife:6.0.0'
compile 'com.squareup:otto:1.3.5'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.squareup.retrofit:retrofit:1.8.0'
compile 'com.squareup.okhttp:okhttp:2.1.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:1.6.0'
compile 'com.path:android-priority-jobqueue:1.1.2'
compile 'com.google.android.gms:play-services-base:6.5.87' // Analytics, GCM
compile 'com.google.android.gms:play-services-maps:6.5.87'
compile 'com.google.android.gms:play-services-location:6.5.87'
compile 'com.android.support:support-v13:21.0.0'
}
Gradle console output:
Error:Class android.support.v4.util.TimeUtils has already been added to output. Please remove duplicate copies.
1 error; aborting
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Users/MyMAC/Documents/Development/IDE's/adt-bundle-mac-x86_64-20140702/sdk/build-tools/19.1.0/dx --dex --no-optimize .........
Error Code:
1
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Landroid/support/v4/util/TimeUtils;
at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
at com.android.dx.command.dexer.Main.processClass(Main.java:685)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
at com.android.dx.command.dexer.Main.access$600(Main.java:78)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
1 error; aborting
Information:BUILD FAILED
remove android-support-v4 in libs folder in facebook proj or your app module
Related
I need some help for integrating library.
I'm getting following error while compiling android project:
Could not resolve com.github.npanigrahy:Custom-Calendar-View:v1.0.
Following is detailed files:
Top-level build.gradle
// 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.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" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
project build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '24.0.1'
defaultConfig {
applicationId "com.test.test"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.github.npanigrahy:Custom-Calendar-View:v1.0'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:recyclerview-v7:24.+'
}
stack trace
Error:A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
Could not resolve com.github.npanigrahy:Custom-Calendar-View:v1.0.
Required by:
STYYLE:app:unspecified
> Could not resolve com.github.npanigrahy:Custom-Calendar-View:v1.0.
> Could not get resource 'https://jcenter.bintray.com/com/github/npanigrahy/Custom-Calendar-View/v1.0/Custom-Calendar-View-v1.0.pom'.
> Could not GET 'https://jcenter.bintray.com/com/github/npanigrahy/Custom-Calendar-View/v1.0/Custom-Calendar-View-v1.0.pom'.
> RSA premaster secret error
> Could not resolve com.github.npanigrahy:Custom-Calendar-View:v1.0.
> Could not get resource 'https://repo1.maven.org/maven2/com/github/npanigrahy/Custom-Calendar-View/v1.0/Custom-Calendar-View-v1.0.pom'.
> Could not GET 'https://repo1.maven.org/maven2/com/github/npanigrahy/Custom-Calendar-View/v1.0/Custom-Calendar-View-v1.0.pom'.
> RSA premaster secret error
> Could not resolve com.github.npanigrahy:Custom-Calendar-View:v1.0.
> Could not get resource 'https://jitpack.io/com/github/npanigrahy/Custom-Calendar-View/v1.0/Custom-Calendar-View-v1.0.pom'.
> Could not GET 'https://jitpack.io/com/github/npanigrahy/Custom-Calendar-View/v1.0/Custom-Calendar-View-v1.0.pom'.
> RSA premaster secret error
Thanks in advance.
In my case, issue was JDK android studio was using.
After changing it to embedded JDK in project settings,error was gone.
Edit:
I changed this line:
compile 'com.google.android.gms:play-services-analytics:8.1.0'
To:
compile 'com.google.android.gms:play-services-analytics:8.4.0'
I changed the classpath to be:
classpath 'com.google.gms:google-services:2.0.0-alpha7'
And updated the gradle version to 2.10 to fix the other issue I mentioned. Now I am having this error whenever I build:
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 8.3.0.
--------------------------------------------------------------------------------------------------------------------------
Original Question
Out of nothing, my app wouldn't successfully build. I tried updating google-services and still I am getting an error.
What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.transform.api.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/ads/identifier/AdvertisingIdClient$Info.class
I am also getting an error in my gradle, at the line:
compile 'com.google.android.gms:play-services-analytics:8.1.0'
saying that some google libraries are of version 8.4.0 and some in 8.1.0. I tried upgrading the google library to 8.4.0. The gradle won't build and gives me the following error:
Warning:Gradle version 2.10 is required. Current version is 2.8. If
using the gradle wrapper, try editing the distributionUrl in
/Users/essam/Desktop/Apptuto/gradle/wrapper/gradle-wrapper.properties
to gradle-2.10-all.zip
Here is my gradle
// 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:1.3.0'
classpath 'com.google.gms:google-services:1.4.0-beta3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
The app gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: "findbugs"
apply plugin: "pmd"
android {
android {
useLibrary 'org.apache.http.legacy'
}
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "my package name is written here"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.1"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
shrinkResources false
}
debug {
debuggable true
}
}
}
findbugs {
ignoreFailures = true
toolVersion = "2.0.1"
reportsDir = file("$project.buildDir/reports/findbugs")
effort = "max"
}
pmd {
ignoreFailures = true
reportsDir = file("$project.buildDir/reports/pmd")
ruleSets = [
"basic",
"braces"
]
}
dependencies {
compile('com.mikepenz:materialdrawer:4.3.7#aar') {
transitive = true
}
repositories {
mavenCentral()
maven {
url 'https://dl.bintray.com/intercom/intercom-maven'
}
}
compile('io.intercom.android:intercom-sdk:1.+#aar') {
transitive = true
}
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.pkmmte.view:circularimageview:1.1'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.google.android.gms:play-services-analytics:8.1.0'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'org.apache.httpcomponents:httpmime:4.2.3'
compile 'com.mixpanel.android:mixpanel-android:4.6.4'
compile 'info.hoang8f:android-segmented:1.0.6'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-v4:23.1.1'
}
it's a rule that all google play services should be using the same version
while I can see only one line using 8.1.0, you might have another library using 8.4.0 , just edit yours to 8.4.0 instead of 8.1.0
now for the other error, I don't know, it didn't happen to me I copied your exact gradle and it compiled
if it kept appearing, try removing your second line:
apply plugin: 'com.google.gms.google-services'
why are you using this any way?
I'm suddenly running into this issue when building/running my project.
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Users/aidanfollestad/Documents/android-sdk/build-tools/21.1.2/dx --dex --no-optimize --output /Users/aidanfollestad/Android Projects/Impression/app/build/intermediates/dex/debug --input-list=/Users/aidanfollestad/Android Projects/Impression/app/build/intermediates/tmp/dex/debug/inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
My Gradle file contains this:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.14.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'versionPlugin'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.afollestad.impression"
minSdkVersion 16
targetSdkVersion 21
versionCode 19
versionName "0.7.0"
}
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile 'com.android.support:appcompat-v7:21.0.+'
compile 'com.android.support:recyclerview-v7:21.0.+'
compile 'com.koushikdutta.ion:ion:2.0.+'
compile 'com.github.chrisbanes.photoview:library:1.2.+'
compile 'com.afollestad:material-dialogs:0.4.5'
compile 'com.google.android.gms:play-services:6.5.87'
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.api-client:google-api-client-gson:1.18.0-rc'
compile 'com.google.apis:google-api-services-drive:v2-rev152-1.19.0'
compile('com.crashlytics.sdk.android:crashlytics:2.1.0#aar') {
transitive = true;
}
}
versionPlugin{
buildTypesMatcher = 'release'
supportBuildNumber = false
fileNameFormat = '$appPkg-v$versionName-$versionCode'
}
My material-dialogs library references only AppCompat-v7, the same version this Gradle file is referencing. I don't have any JARs in my libs folder that I'm referencing. I have no idea what libraries are interfering with each other (other than the possibility of Play Services and AppCompat?). Any ideas or solutions?
I noticed Ion references v4 of the support library (https://github.com/koush/ion/blob/master/ion/build.gradle#L17), maybe that could be interfering with AppCompat?
Try to enable multidex build.gradle :
android {
defaultConfig {
...
multiDexEnabled = true
}
}
Ref : Unable to execute dex: method ID not in [0, 0xffff]: 65536
You may hitted the 65k methods limit. Instead of using multiDex, try to use Google Play Services with more granularity. Follow this guide, you can use only parts that you want. Probably this will fix your problem.
This exception shows that your project have reached to maximum number of methods 65536. you just do the below work.It worked for me
Step 1:
inside build.gradle
defaultConfig {
multiDexEnabled = true
}
Step 2:
inside manifest application tag
android:name="android.support.multidex.MultiDexApplication"
or
Step 3: if You use Class which extends Application then do:
public class MyApplication extends Application {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Step 4:
inside build.gradle
android{
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
}
i know this question has been answered a many times,i tried all ways bt not working for me at all. I refered a lib in android studio,build the project and am getting the following error:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\manalim\AppData\Local\Android\android-studio\sdk\build-tools\android-4.4.2\dx.bat --dex --output E:\MigrationFromEclTostudio\app\build\libs\app-debug.dex E:\MigrationFromEclTostudio\app\build\classes\debug E:\MigrationFromEclTostudio\app\build\dependency-cache\debug E:\MigrationFromEclTostudio\app\build\pre-dexed\debug\classes-9f889413450cab598adf7f9e7fbc4b615d2af144.jar E:\MigrationFromEclTostudio\app\build\pre-dexed\debug\google-play-services-cbe976cd78aae99b019ba10bdd87d55acb9949b6.jar E:\MigrationFromEclTostudio\app\build\pre-dexed\debug\simple-xml-2.6.1-07b87981e87a36154f3c945922849669a8a391c7.jar E:\MigrationFromEclTostudio\app\build\pre-dexed\debug\support-v4-19.0.1-94b91e1fee2be61286a1fe04c97fca852e863a63.jar
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
below is the build.gradle:
**apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 14
targetSdkVersion 18
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:+'
compile 'com.google.android.gms:play-services:+'
compile files('libs/google-play-services.jar')
compile files('libs/simple-xml-2.6.1.jar')
}
**
build.gradle for app:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
thats it..help would be really appreciated as am working oj it since a very long time..
Thanks & Regards.
Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode
Try removing com.google.admobsdk-googleplay or similar if you already have it, it seems like another plugin is already including the need libraries.
The solution is to remove this line:
compile files('libs/google-play-services.jar')
and to delete the corresponding jar from the lib folder. This is not necessary any more because of this line:
compile 'com.google.android.gms:play-services:+'
Also note that you should generally not put a + there but rather maintain a fixed version number to ensure your app's stability.
E.g.
compile 'com.google.android.gms:play-services:6.5.87'
I am trying to use the Facebook SDK in a project in Android Studio. I am following step 3 of this tutorial. When I try to Run the app, I get a "Gradle: Execution failed for task ':FacebookApp:dexDebug'." error. Below is the output if the error
Gradle: Execution failed for task ':FacebookApp:dexDebug'.
> Failed to run command:
C:\android-sdk\build-tools\18.0.0\dx.bat --dex --output C:\Users\Brandon\AndroidStudioProjects\FacebookAppProject\FacebookApp\build\libs\FacebookApp-debug.dex C:\Users\Brandon\AndroidStudioProjects\FacebookAppProject\FacebookApp\build\classes\debug C:\Users\Brandon\AndroidStudioProjects\FacebookAppProject\FacebookApp\build\dependency-cache\debug C:\Users\Brandon\AndroidStudioProjects\FacebookAppProject\FacebookApp\build\exploded-bundles\FacebookAppProjectLibrariesFacebookUnspecified.aar\classes.jar C:\Users\Brandon\AndroidStudioProjects\FacebookAppProject\FacebookApp\build\exploded-bundles\FacebookAppProjectLibrariesFacebookUnspecified.aar\libs\android-support-v4.jar C:\android-sdk\extras\android\m2repository\com\android\support\support-v4\13.0.0\support-v4-13.0.0.jar
Error Code:
1
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoIcsImpl;
at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
at com.android.dx.command.dexer.Main.processClass(Main.java:490)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459)
at com.android.dx.command.dexer.Main.access$400(Main.java:67)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:398)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
at com.android.dx.command.dexer.Main.processOne(Main.java:422)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333)
at com.android.dx.command.dexer.Main.run(Main.java:209)
at com.android.dx.command.dexer.Main.main(Main.java:174)
at com.android.dx.command.Main.main(Main.java:91)
1 error; aborting
Here is the build.gradle for the facebook module:
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
dependencies {
compile files('libs/android-support-v4.jar')
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
And the build.gradle for the project:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:13.0.+'
compile project(':libraries:facebook')
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
Am I doing something wrong?
You're adding the android support library twice, resulting in a dex merge conflict. Your main project refers to the maven library with 'com.android.support:support-v4:13.0.+' and your Facebook project refers to it with files('libs/android-support-v4.jar'). Gradle cannot resolve conflicts between local jar files, so you must refer to them through maven.
Modify the dependencies section of your Facebook build.gradle to:
dependencies {
compile 'com.android.support:support-v4:13.0.+'
}
and everything should work.
In android studio, this is how I include a support library and facebook SDK. I'm supporting API 15+.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'fr.avianey:facebook-android-api:+#aar'
compile 'com.android.support:support-v13:20.0.0'
...
}
I had a similiar issue and it was just plain oversight on my part. I had conflicting versions of com.android.tools.build:gradle:1.1.2 and 1.1.1 inside two different gradle.build files.
app/gradle.build
dependencies {
...
compile 'com.android.tools.build:gradle:1.1.2'
...
}
top-level gradle.build
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
I commented out the line in my project's gradle.build file, ran gradlew clean from the command line, restarted Android Studio and then order was restored in the universe.