"Program type already present" 指的是项目内有同名的类, 即 AnimRes 在项目中存在不同的版本;
多处存在同名文件, 一般是依赖库中有重复的依赖(一个包含的依赖可能依赖了其它依赖, 造成库相同但是版本不同);
使用 "./gradlew app:dependencies" 查看 app 这个模块的依赖库需要的依赖库;
debugAndroidTestCompileClasspath - Resolved configuration for compilation for variant: debugAndroidTest +--- com.android.databinding:baseLibrary:3.1.1 +--- com.android.databinding:library:3.1.1 | +--- android.arch.lifecycle:runtime:1.0.3 -> 1.1.0 | | +--- android.arch.lifecycle:common:1.1.0 | | | \--- com.android.support:support-annotations:26.1.0 -> 27.1.1 | | +--- android.arch.core:common:1.1.0 | | | \--- com.android.support:support-annotations:26.1.0 -> 27.1.1 | | \--- com.android.support:support-annotations:26.1.0 -> 27.1.1 | +--- com.android.support:support-core-utils:26.1.0 -> 27.1.1 | | +--- com.android.support:support-annotations:27.1.1 | | \--- com.android.support:support-compat:27.1.1 | | +--- com.android.support:support-annotations:27.1.1 | | \--- android.arch.lifecycle:runtime:1.1.0 (*) | \--- com.android.databinding:baseLibrary:3.1.1 +--- com.android.databinding:adapters:3.1.1 | +--- com.android.databinding:baseLibrary:3.1.1 | \--- com.android.databinding:library:3.1.1 (*) +--- com.android.support:appcompat-v7:27.1.1 | +--- com.android.support:support-annotations:27.1.1 | +--- com.android.support:support-core-utils:27.1.1 (*) | +--- com.android.support:support-fragment:27.1.1 | | +--- com.android.support:support-compat:27.1.1 (*) | | +--- com.android.support:support-core-ui:27.1.1 | | | +--- com.android.support:support-annotations:27.1.1 | | | +--- com.android.support:support-compat:27.1.1 (*) | | | \--- com.android.support:support-core-utils:27.1.1 (*) | | +--- com.android.support:support-core-utils:27.1.1 (*) | | +--- com.android.support:support-annotations:27.1.1 | | +--- android.arch.lifecycle:livedata-core:1.1.0 | | | +--- android.arch.lifecycle:common:1.1.0 (*) | | | +--- android.arch.core:common:1.1.0 (*) | | | \--- android.arch.core:runtime:1.1.0 | | | \--- android.arch.core:common:1.1.0 (*) | | \--- android.arch.lifecycle:viewmodel:1.1.0 | +--- com.android.support:support-vector-drawable:27.1.1 | | +--- com.android.support:support-annotations:27.1.1 | | \--- com.android.support:support-compat:27.1.1 (*) | \--- com.android.support:animated-vector-drawable:27.1.1 | +--- com.android.support:support-vector-drawable:27.1.1 (*) | \--- com.android.support:support-core-ui:27.1.1 (*) +--- com.android.support.constraint:constraint-layout:1.1.3 | \--- com.android.support.constraint:constraint-layout-solver:1.1.3 +--- org.greenrobot:eventbus:3.1.1 +--- com.android.support:recyclerview-v7:27.1.1 | +--- com.android.support:support-annotations:27.1.1 | +--- com.android.support:support-compat:27.1.1 (*) | \--- com.android.support:support-core-ui:27.1.1 (*) \--- com.ibm.icu:icu4j:60.2AnimRes 包含在 com.android.support:support-annotations 中, 如果是依赖的库存在相互依赖, 造成版本不同, 会出现多个不同版本号的 support-annotations;
如果发现有不同版本号, 可以使用下列方法解决;
// 在 Module 的 build.gradle 中添加 configurations { compile.exclude group: 'com.android.support', module: 'support-annotations'Theme by Lophita