Android Studio找不到android-support-V7

时间:2015-08-20 08:13:12

标签: android android-studio android-support-library

错误:

{
    "data": 
    [
        {
            "score": 1,
            "user": 
            {
                "name": "1st Name",
                "id": "first_id"
            }
        },
        {
            "score": 0,
            "user": 
            {
                "name": "2nd Name",
                "id": "2nd_id"
            }
        }
    ]
}

我的项目信息: Android Studio工作区:

  1. 项目A依赖项目B和C;

  2. 项目B依赖项目C;

  3. Project B&#39的build.gradle     apply plugin:' android-library'

    E:\tmp\xxx\PullToRefresh\src\com\handmark\pulltorefresh\library\PullToRefreshRecyclerView.java:55: error: can not access ScrollingView
            recyclerView.setId(R.id.recyclerview);
                        ^
      can not access android.support.v4.view.ScrollingView 
    E:\tmp\xxx\PullToRefresh\src\com\handmark\pulltorefresh\library\PullToRefreshRecyclerView.java:61: error: can not access NestedScrollingChild
            if (mRefreshableView.getChildCount() <= 0)
                                ^
      con not find android.support.v4.view.NestedScrollingChild 
    

    投射C&#39的build.gradle:

    dependencies {
        compile fileTree(include: '*.jar', dir: 'libs')
    //    compile 'com.android.support:recyclerview-v7:22.2.+'
        compile project(':Recyclerview')
    }
    

    根本原因: Project C使用com.android.support:recyclerview-v7

    的jar

    但是Project B已经在build.gradle中使用它,如下所示:

    apply plugin: 'android-library'
    
    dependencies {
        compile fileTree(include: '*.jar', dir: 'libs')
    }
    

    但是当我制作项目时,我会得到上述错误。

    PS: 我的操作系统是Windows 7 Android Studio版本:1.3.1

    顺便说一句,在我的Ubuntu上,同样的项目一切正常!

2 个答案:

答案 0 :(得分:0)

如果支持库没有2日期,那就会发生这种情况。

打开您的sdk管理器,下载最新版本的支持存储库和库。在这2个中有所有compat / style / support库。

我认为你的ubuntu安装已经开始了2个日期。

enter image description here

那些标记为红色的2个,需要2个日期。我认为他们不在你的基于Windows的系统上。

答案 1 :(得分:0)

解决方案

dependencies {      

compile ('com.android.support:recyclerview-v7:22.2.1'){
        exclude module: 'support-v4' //by artifact name
        exclude group: 'com.android.support' //by group
        exclude module: 'support-annotations'
        exclude group: 'com.android.support', module: 'support-v4' //by both name and group

    }

}

// or below

configurations {
    all*.exclude group: 'com.android.support', module: 'multidex'
    all*.exclude group: 'com.android.support', module: 'support-v4'
}