Your problem is that wherever you link the library to the main project, you have the same dependencies between them for your support library and annotations.
If you have a library project as a dependency in your application, you only need the dependency, which will be placed in closing the library dependencies.
The problem is that you have two dex files, because there are two files with the same name, because they overlap in the files with your dependencies.
First copy your module to your libs / main folder of the main project, then
create the settings.gradle file in the root of the main project:
include 'app_name', 'library_name' project(':LibraryNameGoesHere').projectDir = new File('libs/LibraryNameGoesHere')
For your build.gradle library
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 build.gradle project
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.0.+' compile project(":libs:LibraryNameGoesHere") }
source share