[英]Android design support library - version number and gradle error
I am trying to implement the CoordinatorLayout and Snackbar into my first app. 我正在尝试在我的第一个应用程序中实现CoordinatorLayout和Snackbar。 I know that I need to add an Android design support library as a dependency in the build.gradle file but I am getting the following error in Android Studio 2.3.1:
我知道我需要在build.gradle文件中添加一个Android设计支持库作为依赖项,但是在Android Studio 2.3.1中遇到以下错误:
Failed to resolve: com.android.support.design:25.3.1
无法解决:com.android.support.design:25.3.1
Install Repository and sync project
安装存储库并同步项目
Open File
打开文件
I think there are 2 possible problems: 我认为可能有2个问题:
Here are the dependencies in my build.gradle file: 这是我的build.gradle文件中的依赖项:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support.design:25.3.1'
testCompile 'junit:junit:4.12'
}
And in the activity_main.xml layout file: 并在activity_main.xml布局文件中:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
...
</android.support.design.widget.CoordinatorLayout>
I have found similar questions on SO with gradle build errors but the response is often something along the lines of the advice below which I don't understand, particularly step 3. 我在SO上发现了类似的问题,并且存在gradle构建错误,但是响应通常是以下我不理解的建议,尤其是第3步。
File -> Invalidate caches / Restart
文件->使缓存无效/重新启动
Shutdown Android Studio
关闭Android Studio
Rename/remove .gradle folder in the user home directory
重命名/删除用户主目录中的.gradle文件夹
Restart Android Studio let it download all the Gradle stuff it needs
重新启动Android Studio,让其下载所需的所有Gradle内容
Gradle build success !
Gradle建立成功!
Rebuild project.... success !
重建项目。...成功!
I would try this except I don't know where to find the .gradle folder? 除了不知道在哪里找到.gradle文件夹外,我将尝试这样做。
You have the following line: 您有以下几行:
compile 'com.android.support.design:25.3.1'
It should be: 它应该是:
compile 'com.android.support:design:25.3.1'
Notice the ':' instead of '.' 注意“:”而不是“。” between 'support' and 'design'.
在“支持”和“设计”之间。
25.3.1 is the correct version at the moment. 25.3.1目前是正确的版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.