Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在两个官方android库中重复类,gradle失败_Android_Annotations_Android Gradle Plugin_Render_Libs - Fatal编程技术网

在两个官方android库中重复类,gradle失败

在两个官方android库中重复类,gradle失败,android,annotations,android-gradle-plugin,render,libs,Android,Annotations,Android Gradle Plugin,Render,Libs,我使用的库需要激活渲染脚本支持模式。像这样 defaultConfig { minSdkVersion 14 targetSdkVersion 23 renderscriptTargetApi 20 renderscriptSupportModeEnabled true } 但当我尝试运行该应用程序时,我发现: Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'. java.util.zip

我使用的库需要激活渲染脚本支持模式。像这样

defaultConfig {

 minSdkVersion 14
 targetSdkVersion 23
 renderscriptTargetApi 20
 renderscriptSupportModeEnabled true
}
但当我尝试运行该应用程序时,我发现:

Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: android/support/annotation 
/Keep.class

Keep.class位于注释支持库和
rendservscript
lib中,两者都来自谷歌,所以我不知道该怎么做。

此错误仅发生在最新(23)SDK版本中。您是否可以尝试将构建版本更改为22或21,同时更改依赖项

例如

android {
       compileSdkVersion 21
        buildToolsVersion "21.1.2"
}
dependencies {

    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.android.support:support-v4:21.0.3'  
}

我对build.gradle文件进行了以下修改,现在可以正常工作了:

renderScriptTargetApi 23

并补充说

configurations{all*.exclude group:'com.android.support',module:'support annotations'}


我相信这是第二行成功了。

在谷歌修复之前,这似乎是唯一的选择。谢谢。我不确定这是否是现在最好的方法。我知道这可能有效,不包括lib,但我不能失去支持注释。无论如何,谢谢你。