Android Studio 找不到android-support-V7
Android Studio can not find android-support-V7
错误:
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
我的项目信息:
Android 工作室工作区:
项目A依赖项目B和C;
项目B依赖项目C;
项目 B 的 build.gradle
应用插件:'android-library'
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
// compile 'com.android.support:recyclerview-v7:22.2.+'
compile project(':Recyclerview')
}
项目 C 的 build.gradle:
apply plugin: 'android-library'
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
}
根本原因:
项目 C 使用 com.android.support:recyclerview-v7
的 jar
但项目 B 已在 build.gradle 中使用它,如下所示:
compile project(':Recyclerview')
但是我做project的时候会出现如上的错误
PS:
我的 OS 是 Windows 7
Android工作室版本:1.3.1
顺便说一句,在我的 Ubuntu 同一个项目上一切正常!
如果支持库未更新 2 就会发生这种情况。
打开你的sdk管理器,下载最新版本的support Repository and Library。在这 2 个中有所有 compat/style/support 个库。
我假设您的 ubuntu 安装是最新的 2。
标记为红色的 2 个,需要更新 2 个日期。我假设它们不在您基于 windows 的系统上。
解决方法
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'
}
错误:
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
我的项目信息: Android 工作室工作区:
项目A依赖项目B和C;
项目B依赖项目C;
项目 B 的 build.gradle 应用插件:'android-library'
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
// compile 'com.android.support:recyclerview-v7:22.2.+'
compile project(':Recyclerview')
}
项目 C 的 build.gradle:
apply plugin: 'android-library'
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
}
根本原因: 项目 C 使用 com.android.support:recyclerview-v7
的 jar但项目 B 已在 build.gradle 中使用它,如下所示:
compile project(':Recyclerview')
但是我做project的时候会出现如上的错误
PS: 我的 OS 是 Windows 7 Android工作室版本:1.3.1
顺便说一句,在我的 Ubuntu 同一个项目上一切正常!
如果支持库未更新 2 就会发生这种情况。
打开你的sdk管理器,下载最新版本的support Repository and Library。在这 2 个中有所有 compat/style/support 个库。
我假设您的 ubuntu 安装是最新的 2。
标记为红色的 2 个,需要更新 2 个日期。我假设它们不在您基于 windows 的系统上。
解决方法
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'
}