Trouble with building android project with Gradle (Multiple dex files) - android

Since the release of 1.0, I'm finally moving over to AS.. I don't have too much experience with Gradle, so bear with me. I've found a couple of answers that seem to be putting me on the right track, however, I've yet to find a generic answer that will help me. (Most of the answers are just "replace your jar with this.."). It seems as though I have a dependency linked twice somewhere, however, I'm not quite sure where...
Here is the error I am getting
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/view/PagerAdapter;
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)
And here are my dependencies on my main project:
dependencies {
compile project(':swipeBackLibrary')
compile 'com.android.support:appcompat-v7:19.1.0'
compile files('libs/android-support-v13.jar')
compile files('libs/libGoogleAnalyticsServices.jar')
}
I'm guessing I have a collision somewhere. How can I check where PagerAdapter is getting its source(s)? Thanks guys.

The appcompat library includes the support library, which is where the duplication comes from. Since you've included the support library as a jarfile instead of referring to it via Maven coordinates, the build system can't disambiguate the multiple copies of the library and prevent the error. You can fix it by moving to a coordinate-based spec for the support library:
dependencies {
compile project(':swipeBackLibrary')
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.android.support:support-v13:19.1.0'
compile files('libs/libGoogleAnalyticsServices.jar')
}

Related

Android Studio: Multiple dex files define Lcom/sun/activation/registries/LineTokenizer;

Receiving this exception whilst trying to build my project. Have searched around for an answer but most cases seem to be different to mine.
Other solutions include clearing temporary files or doing a gradle clean. This does temporarily solve the issue but it reappears again after a few builds. Another way this issue can occur is if the project contains multiple copies of a library. I have searched through my project and only have one instance of activation.jar which is in my libs directory. Most other solutions seem to involve changing the build path in Eclipse, but my problem is occurring on Android Studio 0.5.8. I am using Java 1.7.
Gradle Console
UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException:
Multiple dex files define
Lcom/sun/activation/registries/LineTokenizer;
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)
Libraries in libs dir:
activation.jar
additionnal.jar
androidplot-core-0.5.1.jar
annotations.jar
DatawindAdsSdk-2.0.jar
jpct_ae.jar
jsr305-1.3.9.jar
libGoogleAnalyticsV2.jar
mail.jar
twitter4j-core-3.0.5.jar
Dependencies: Note - ":android-cropimage" does not have any dependencies in build.gradle
Main module:
dependencies {
//Library Projects
compile project(':android-cropimage')
compile project(':facebook')
//Android SDK Libraries
//This library requires "Google Play Services" and "Google Repository" to be downloaded via SDK Manager.
compile 'com.google.android.gms:play-services:4.4.52'
//Third Party
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abs:+'
compile 'com.jakewharton:butterknife:4.0.1'
compile 'com.j256.ormlite:ormlite-core:4.46'
compile 'com.j256.ormlite:ormlite-android:4.46'
compile 'net.hockeyapp.android:HockeySDK:3.0.1'
compile 'org.apache.httpcomponents:httpmime:4.2.5'
compile 'com.viewpagerindicator:library:2.4.1#aar'
compile 'com.squareup.picasso:picasso:2.2.0'
compile 'com.mcxiaoke.volley:library:1.0.+'
compile 'org.msgpack:msgpack:0.6.11'
}
Facebook module:
dependencies {
compile 'com.android.support:support-v4:19.1.0'
}
Turns out this is due to a bug with the Android Gradle plugin's incremental dex option on version 0.10.2 (https://groups.google.com/forum/#!topic/adt-dev/6KbhReCE_fo). Removing the following from my build.gradle file solved the issue:
android {
dexOptions {
incremental true
}
}
As #Marepork anwered there is a bug withing gradle that has not been fixed
If you still want to use incremental build you can always use build variants and fordebug use multidex and for release a proguard

Import Spring Framework with Gradle 1.11 causes Multiple dex files define error

According to Spring Framework Android quickstart, if you are using Gradle to build your project, you should add the following lines as build dependencies:
dependencies {
compile 'org.springframework.android:spring-android-rest-template:1.+'
compile 'org.springframework.android:spring-android-auth:1.+'
compile 'org.springframework.android:spring-android-core:1.+'
}
However, the following error happens on Gradle 1.11:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define
Lorg/springframework/core/ErrorCoded;
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)
According to this thread at Spring.io, "the Spring for Android rest-template and core artifacts do not have a dependency on spring core or any Spring Framework library. However, the auth dependency does, along with Spring Social".
Thus, a possible solution is marking these repeated dependencies for exclusion:
dependencies {
compile('org.springframework.android:spring-android-auth:1.+') {
exclude group :'org.springframework', module: 'commons-logging'
exclude group :'org.springframework', module: 'spring-core'
exclude group :'org.springframework', module: 'spring-web'
}
compile 'org.springframework.android:spring-android-core:1.+'
compile 'org.springframework.android:spring-android-rest-template:1.+'
}

App with Google Maps doesn't build in Android Studio

I'm trying to build an app with Google Maps but whenever I try to run it there's an error message. I've added the following code to my build.gradle:
dependencies {
compile 'com.google.android.gms:play-services:4.2.42'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
And here's the error message:
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\Fredrik\AppData\Local\Android\android-studio\sdk\build-tools\19.0.3\dx.bat --dex --output
C:\Users\Fredrik\AndroidStudioProjects\Skollunch\app\build\dex\debug
C:\Users\Fredrik\AndroidStudioProjects\Skollunch\app\build\classes\debug
C:\Users\Fredrik\AndroidStudioProjects\Skollunch\app\build\dependency-cache\debug
C:\Users\Fredrik\AndroidStudioProjects\Skollunch\app\build\pre-dexed\debug\android-support-v4-0245b39e700edf6a0cb399c720bb8d324f78e6d1.jar
C:\Users\Fredrik\AndroidStudioProjects\Skollunch\app\build\pre-dexed\debug\classes-05dd9eee723585a17563ec87ce727a6f7bafa3c6.jar
C:\Users\Fredrik\AndroidStudioProjects\Skollunch\app\build\pre-dexed\debug\support-v4-19.0.1-b477505a5fac609297d4a580b1fdd1110916d42b.jar
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
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)
When I delete the code in build.gradle it runs fine, but then Maps won't work of course ;). This isn't just the case with Play Services but it does the same thing when I try to add the Support Library.
Does anyone know something that could help me solve the problem?
When using Gradle, don't include android-support-v4 by including the jar file directly; if you do it this way, the build system isn't able to disambiguate multiple copies of the support library it may encounter through direct or transitive dependencies, and you get exactly this error. Instead, remove the jar from your libs directory and include it by supplying its Maven coordinate in the dependencies block of your build file:
dependencies {
compile 'com.google.android.gms:play-services:4.2.42'
compile 'com.android.support:support-v4:+'
compile fileTree(dir: 'libs', include: ['*.jar'])
}

Android Studio - UNEXPECTED TOP-LEVEL EXCEPTION:

I have built a new project in Android Studio using the new project templates provided as part of the tool. All of the code has been generated by Studio I have not made any amendments yet.
I am attempting to run the code but the app fails with the following errors, not sure what the problem is so any help appreciated.
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v7/app/ActionBar$Callback;
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)
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\RichardKavanagh\AppData\Local\Android\android-sdk\build-tools\19.0.1\dx.bat --dex --output D:\Android\Projects\MyHealthRecord\app\build\libs\app-debug.dex D:\Android\Projects\MyHealthRecord\app\build\classes\debug D:\Android\Projects\MyHealthRecord\app\build\dependency-cache\debug D:\Android\Projects\MyHealthRecord\app\build\pre-dexed\debug\android-support-v7-appcompat-5a78dab7e2789bbe64f4bc80d106ca75c04dcf6f.jar D:\Android\Projects\MyHealthRecord\app\build\pre-dexed\debug\classes-f9b947272e9f33ba50355b52d82755584f9c0c58.jar D:\Android\Projects\MyHealthRecord\app\build\pre-dexed\debug\support-v4-19.0.0-31a2c13df80d37d62ca50fec3bde6da0ca706223.jar
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v7/app/ActionBar$Callback;
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)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 12.948 secs
Like everyone else said here, the support library (com.android.support) is being included more than once in your project. Try adding this in your build.gradle at the root level and it should exclude the support library from being exported via other project dependencies.
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
If you have more then one support libs included in the dependencies like this, you may want to remove one of them:
dependencies {
compile 'com.android.support:support-v4:19.1.+'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
This gets conflicted if you have the support jar in your libs folder.
If you have the support jar in your project libs folder and you have the module dependency added to compile 'com.android.support:support-v4:13.0.+' the UNEXPECTED_TOPLEVEL_DEPENDANCY exception will be thrown.
Because you may include two same libs in your project.
check your build.gradle file.
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile files('libs/android-support-v4.jar')
}
if your file includes compile 'com.android.support:appcompat-v7:+' and compile files('libs/android-support-v4.jar'), it will have this problems.
delete this sentence: compile files('libs/android-support-v4.jar')
That's how I fix this problem.
The error occurs when you have the same library/directory included more than once in your build.gradle's dependencies. Ok, let’s say you have an App structure that looks like this:
So you have the main “app” and then you have a bunch of sub-apps/modules/libraries. The libraries are: 1) gene_test_library, 2) genes_nine_old_androids_library, & 3) swipe_list_view_library.
My name is Gene, so that’s why there are all these “gene” libraries.
Inside the build.gradle for “app”, I have:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.0'
compile project(':libraries:gene_test_library')
//compile project(':libraries:genes_nine_old_androids_library')
compile project(':libraries:swipe_list_view_library')
}
Inside the build.gradle for gene_test_library, I have nothing:
dependencies {
}
Inside build.gradle for gene_nine_old_androids_library, I have:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.0'
}
Inside build.gradle for swipe_list_view_library, I have:
dependencies {
compile 'com.nineoldandroids:library:2.4.0+'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.0'
}
This line of code “compile fileTree(dir: 'libs', include: ['*.jar'])” just means “hey, look inside the ‘libs’ folder inside this module for any jar files. I do not have anything in the libs folder of any of the modules so you can ignore that line of code.
So let’s say I uncomment out //compile project(':libraries:genes_nine_old_androids_library')
In the build.gradle for the “app” module. Then I would get the “UNEXPECTED TOP-LEVEL EXCEPTION:” error. Why is that?
Well, writing //compile project(':libraries:genes_nine_old_androids_library') inside the build.gradle for “app”, is the same as taking the build dependencies of “genes_nine_old_androids_library” module and putting it there. So uncommenting the //compile project(':libraries:genes_nine_old_androids_library') statement, the build.gradle for “app” module becomes:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.0'
compile project(':libraries:gene_test_library')
***compile fileTree(dir: 'libs', include: ['*.jar'])***
***compile 'com.android.support:appcompat-v7:21.0.0'***
compile project(':libraries:swipe_list_view_library')
}
Notice how now “compile 'com.android.support:appcompat-v7:21.0.0'” shows up 2x. That’s where the error is coming from.
I found 2 reason for this issue:
Sometimes its because of multiple included libraries. For example you add
compile 'com.nineoldandroids:library:2.4.0'
in your gradle and add another library that it also use "nineoldandroids" in it's gradle!
As Android Developer Official website said:
If you have built an Android app and received this error, then congratulations, you have a lot of code!
So, why?
The Dalvik Executable specification limits the total number of methods that can be referenced within a single DEX file to 65,536, including Android framework methods, library methods, and methods in your own code. Getting past this limit requires that you configure your app build process to generate more than one DEX file, known as a multidex configuration.
Then what should you do?
Avoiding the 65K Limit - How?
Review your app's direct and transitive dependencies - Ensure any large library dependency you include in your app is used in a manner that outweighs the amount of code being added to the application. A common anti-pattern is to include a very large library because a few utility methods were useful. Reducing your app code dependencies can often help you avoid the dex reference limit.
Remove unused code with ProGuard - Configure the ProGuard settings for your app to run ProGuard and ensure you have shrinking enabled for release builds. Enabling shrinking ensures you are not shipping unused code with your APKs.
Configuring Your App for Multidex with Gradle - How?
1.Change your Gradle build configuration to enable multidex.
put
multiDexEnabled true
in the defaultConfig, buildType, or productFlavor sections of your Gradle build file.
2.In your manifest add the MultiDexApplication class from the multidex support library to the application element.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
Note: If your app uses extends the Application class, you can override the attachBaseContext() method and call MultiDex.install(this) to enable multidex. For more information, see the MultiDexApplication reference documentation.
Also this code may help you:
dexOptions {
javaMaxHeapSize "4g"
}
Put in your gradle(android{ ... } ).
Hi all I had the same issue that was being caused by a duplicate support version 4 file that I had included while trying to get parse integrated. Deleted the extra inclusion from the libs directory and it works fine now!
This happens when a library is getting compiled twice (i.e it is added two time). It can be support library or any other, it doesn't matter.
The common case is that you have added a compile statement of a library which is already in your libs/ directory. All the *.jar files are compiled automatically. Thus, adding a compile statement is causing the error. Removing that statement might fix this issue. If this is not applicable then we already have some awesome answers.
This might be the dumbest answer, but this worked for me :
I removed and added all the libraries on my project manually.(One after the other) And voila, it worked.
Build -> Rebuild project
Note: No library of mine was compiled twice.
Make sure you have downloaded Support Repository to use support library dependency in build.gradle.
If these all are there already installed sync your project with gradle once using the button available.
In my case TOP LEVEL EXCEPTION was throw because of a special char in project path. Just closed the project, changed "á" to "a" and reopened the project. Works!
Suddenly, without any major change in my project, I too got this error.
All the above did not work for me, since I needed both the support libs V4 and V7.
At the end, because 2 hours ago the project compiled with no problems, I simply told Android Studio to REBUILD the project, and the error was gone.
I had similar problem when I tried to build a signed apk for my app.
Strange, it happened only when I wanted to build a release apk, while on debug apk everything worked OK.
Finally, looking on this thread, I checked for support library duplications in build.gradle and removed any duplications but this wasn't enough..
I had to do clean project and only then finally I've got it to work.
I know that the problem was answered, but this could happen again and my solution was a little different from the ones that I found. In my case the solution wasn't related to include two different libraries in my project. See code below:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
This code was giving that error "Unexpected Top-Level Exception".
I fix the code making the following changes:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
I solved my problem with adding these in build gradle:
defaultConfig {
multiDexEnabled true
dependencies {
compile 'com.android.support:multidex:1.0.0'
another solution can be removing unnecessary libraries

Android Studio build error - Multiple dex files define Landroid/support/v4/

I am unable to build my project in Android Studio. I get the following error:
Error:Android Dex: [RaditazAndroid] Unable to execute DX
Error:Android Dex: [RaditazAndroid] com.android.dx.util.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
Error:Android Dex: [RaditazAndroid] at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:592)
Error:Android Dex: [RaditazAndroid] at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:550)
Error:Android Dex: [RaditazAndroid] at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:531)
Error:Android Dex: [RaditazAndroid] at com.android.dx.merge.DexMerger.mergeDexBuffers(DexMerger.java:168)
Error:Android Dex: [RaditazAndroid] at com.android.dx.merge.DexMerger.merge(DexMerger.java:186)
Error:Android Dex: [RaditazAndroid] at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:300)
Error:Android Dex: [RaditazAndroid] at com.android.dx.command.dexer.Main.run(Main.java:232)
Error:Android Dex: [RaditazAndroid] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Error:Android Dex: [RaditazAndroid] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
Error:Android Dex: [RaditazAndroid] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Error:Android Dex: [RaditazAndroid] at java.lang.reflect.Method.invoke(Method.java:597)
Error:Android Dex: [RaditazAndroid] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:147)
Error:Android Dex: [RaditazAndroid] at org.jetbrains.android.compiler.tools.AndroidDxRunner.main(AndroidDxRunner.java:276)
Error:Android Dex: [RaditazAndroid] at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:121)
However, this error means nothing to me. It does not provide clues as to where I should begin fixing my project. Has anybody encountered something similar?
For anyone who is interested, I solved my own problem. My mistake was that I had pasted android-support-v4.jar and google-play-services.jar in all of my project's module lib folders (my project consists of 3 modules). What I had to do instead was to paste these jars only into my main module's lib folder, and the other modules would automatically reference them.
Away from Android Studio, I opened the project in finder/workspace and did this:
1- MyProject folder -> build -> intermediate -> dex-cache -> cache.xml, and deleted all support-v4.jar items.
2- Also away from Android Studio, Went to every module in my project -> lib folder -> and deleted support-v4.jar as well.
Then cleaned the project and ran it and it worked thanks god :)
I had the same error.Solved it by adding to gradle file.
dependencies{
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:support-v4:23.1.0'
}
In case you have:
compile 'com.android.support:recyclerview-v7:24.2.0'
compile('com.android.support:appcompat-v7:23.2.0') { exclude group: 'com.google.android', module: 'support-v4' }
in your project, add also:
compile 'com.android.support:support-v4:24.2.0'
or
compile 'com.android.support:design:24.2.0'
In my case the problem was in module sdk version. I changed it from 2.2 to 4.4 and the problem was solved.
I had the same error.
Removing a library(jtwitter.jar) form my-project/app/libs folder helped me.
Then cleaned the project and ran it and it worked.
Clean and rebuild was all it took for mine to start working.
In case someone else was having this problem with the Project Tango examples provided via Github, I solved it by commenting the following line out in the app's build.gradle file for those projects which failed to run:
compile fileTree(dir: external_lib_prefix + '/jar', include: ['**/*.jar'])
I used a different approach by merging ABS res folder with my res folder and using ActionBarSherlock.jar as a global lib.
Works well so far and hope this help someone! But this is a hack since I was fed up of doing many things and I can't use Gradle since some of the other developers using Eclipse ADT without Gradle.
Root Cause for the issue is using android-support-v4 in ABS and my project both and it's complicating DEX.
I had same issue in Android Studio 2.3, in my case I had a mixture of version numbers which threw the build out, I changed:
dependencies {
compile 'com.google.android.gms:play-services-wearable:7.5.0'
compile 'com.google.android.gms:play-services-analytics:7.5.0'
compile 'com.google.android.gms:play-services-drive:8.4.0'
}
to
dependencies {
compile 'com.google.android.gms:play-services-wearable:8.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-drive:8.4.0'
}
For others wondering why this problem still persist even doing all other things suggested, This may help.
For me problem started when i added Glide library
dependencies {
.........
implementation 'com.github.bumptech.glide:glide:4.8.0'
.........
}
and i had added already.
implementation 'com.android.support:design:26.1.0'
Which was contradicting with Glide support library somewhere.
Solution: Remove or downgrade your Glide support version.
implementation 'com.github.bumptech.glide:glide:4.0.0'

Categories

Resources