机器人工作室:gradle这个相关性错误 [英] android studio: gradle dependency error

查看:234
本文介绍了机器人工作室:gradle这个相关性错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的build.gradle,我增加了部分配置,以避免支持库的双重包容。支持库的主要项目,并在像Facebook SDK中的相关项目中使用。如果没有配置部分,我得到意外的顶级EXCEPTION。并称,配置使得错误消失和应用程序都工作正常。

现在,我想RecyclerView添加到我的应用程序,我得到的,而充气recyclerview没有找到RecyclerView类(虽然它建立确定)。如果我删除Facebook的SDK和配置部分中,recyclerview工作就好了。

问:我可以给的build.gradle什么样的变化,使Facebook的SDK工作和RecyclerView工作?换句话说,为什么不包括V7的配置部分时,只应该排除V4?


  {相关性
    编译文件树(包括:['的* .jar'],DIR:库)
    编译com.android.support:support-v4:+
    编译com.android.support:support-v13:+
    编译com.android.support:cardview-v7:+
    编译com.android.support:recyclerview-v7:+
    编译com.google.android.gms:游戏服务:52年4月4日
    编制项目(:Facebook的3.15')
    编制项目(':解析-1.5.1)
    编制项目(':viewpagerindicator-2.4.1)
}配置{
    //避免支持库包含双
    所有* .exclude组:com.android.support',模块:支持-V4
}


解决方案

找到了解决这个...

1.Removed中的build.gradle的配置部分排除支持-V4


  1. 原来,.aar文件基本上是一个zip,所以删除了.aar库的依赖支持-V4瓶(用7-ZIP)。
    而现在,我没有得到顶级异常,并在同一时间能够使用recyclerview-V7。

如果你是使用依赖的项目,而不是.aar文件,尝试编译之前删除的依赖项目的支持,v4.jar文件。

不应该的Gradle的构建工具足够智能,排除重复的软件包,而不是让用户去通过这个样的解决方法和头痛?

In the following build.gradle, I added the configuration section to avoid double inclusion of support libraries. Support libraries are used in the main project and in the dependent projects like facebook sdk. Without the configuration section, I get "UNEXPECTED TOP-LEVEL EXCEPTION". Adding that configuration makes the error go away and the app all works fine.

Now, I'm trying to add RecyclerView to my app and I get RecyclerView class not found while inflating the recyclerview (although it builds ok). If I remove the facebook SDK and configuration section, the recyclerview works just fine.

Question: What changes can I make to the build.gradle to make the facebook SDK work and RecyclerView work? In other words, why is the config section excluding v7 when it is only supposed to exclude v4?


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:support-v4:+'
    compile 'com.android.support:support-v13:+'
    compile 'com.android.support:cardview-v7:+'
    compile 'com.android.support:recyclerview-v7:+'
    compile 'com.google.android.gms:play-services:4.4.52'
    compile project(':facebook-3.15')
    compile project(':parse-1.5.1')
    compile project(':viewpagerindicator-2.4.1')
}

configurations {
    // to avoid double inclusion of support libraries
    all*.exclude group: 'com.android.support', module: 'support-v4'
}

解决方案

Found a solution to this...

1.Removed the config section in the build.gradle that excludes support-v4

  1. It turns out that .aar files are basically a zip, so removed the support-v4 jar from the dependency .aar library (using 7-zip). And now, I don't get the top-level exception and at the same time able to use recyclerview-v7.

If you are using dependency projects instead of .aar files, try removing the support-v4.jar files in the dependency projects before compiling.

Shouldn't the gradle build tool be intelligent enough to exclude the duplicate packages rather than having the users go thru this kind of workarounds and headaches?

这篇关于机器人工作室:gradle这个相关性错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆