Multiple Dex Files Define Landroid/Support/Annotation/Animres

multiple dex files define landroid/support/annotation/AnimRes

The problem is that android-support-annotations.jar used to be a separate library containing the android annotations, but for some reason these annotations are already included in recent versions of the android-support-v4.jar file.

Deleting the annotations jar solved the issue.

com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;

Your problem i believe is that wherever you are linking the Library to your Main Project you have the same dependencies between the two for your support library and annotations.

If you have the library project as a dependency in your application you will only need the dependency to be placed in the library dependencies closure.

The issue is that you have two dex files because there are two Files with the same name because the overlap in files with your dependencies.

First copy your module to your libs/ folder of your main project then,

create your settings.gradle file in the root of the main project:

include 'app_name', 'library_name'
project(':LibraryNameGoesHere').projectDir = new File('libs/LibraryNameGoesHere')

For your library's build.gradle

dependencies {
compile files('libs/android-support-v4.jar')
compile 'com.android.support:support-v4:22.0.+'
compile 'com.android.support:support-annotations:20.0.0'
}

Then for your main project build.gradle

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.+'
compile project(":libs:LibraryNameGoesHere")
}

Multiple dex files define Landroid/support/annotation/AnimRes Error.How to find repeated references?

Try this code in your build.gradle inside andoid{ }:

defaultConfig { 
multiDexEnabled true
}

Multiple dex files define Landroid/support/design/widget/CoordinatorLayout$LayoutParams

Update the library versions to 27.1.0 solve the isssue for me.

compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:mediarouter-v7:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:support-v13:26.1.0'
compile 'com.android.support:support-v4:26.1.0'

To:

compile 'com.android.support:appcompat-v7:27.1.0'
compile 'com.android.support:design:27.1.0'
compile 'com.android.support:appcompat-v7:27.1.0'
compile 'com.android.support:mediarouter-v7:27.1.0'
compile 'com.android.support:recyclerview-v7:27.1.0'
compile 'com.android.support:cardview-v7:27.1.0'
compile 'com.android.support:support-v13:27.1.0'
compile 'com.android.support:support-v4:27.1.0'

Error:com.android.dex.DexException: Multiple dex files define Landroid/support/design/widget/CoordinatorLayout$HierarchyChangeListener

You need to add the following in your build.gradle

configurations.all {
resolutionStrategy {
force 'com.android.support:design:27.0.2'
force 'com.android.support:support-v4:27.0.2'
force 'com.android.support:appcompat-v7:27.0.2'
}
}

For more information you might consider reading from this link.

UNEXPECTED TOP_LEVEL EXCEPTION Multiple dex files define Landroid/support/annotation/AnimRes

It happens when you are using 2 different versions of the same library.

You can render the dependency tree with the command gradle dependencies

In your case:

'com.getbase:floatingactionbutton:1.6.0' uses

    <dependency>
<groupId>com.android.support</groupId>
<artifactId>support-annotations</artifactId>
<version>19.1.0</version>
</dependency>

while you appcompat 21.0.3 uses

<dependency>
<groupId>com.android.support</groupId>
<artifactId>support-annotations</artifactId>
<version>21.0.3</version>
<scope>compile</scope>
</dependency>

You can check if there is a updated version that uses the same 21.0.3 or you can exclude the dependency with:

compile('com.getbase:floatingactionbutton:1.6.0') {
exclude group: 'com.android.support', module: 'support-annotations'
}


Related Topics



Leave a reply



Submit