简体   繁体   English

如何在Android Studio项目上导入Material Design

[英]How to import Material Design on Android Studio project

I want to use this Material Design : 我想使用这种材料设计:

https://github.com/navasmdc/MaterialDesignLibrary https://github.com/navasmdc/MaterialDesignLibrary

I have Imported it into my project and changed version numbers in build.gradle of it to versions of build.gradle of my app 我已将其导入到我的项目中,并将其build.gradle的版本号更改为我的应用程序的build.gradle版本

Now there is a build error : 现在有一个构建错误:

Error:(24, 13) Failed to resolve: com.nineoldandroids:library:2.4.+ 错误:(24,13)无法解决:com.nineoldandroids:library:2.4。+

I have searched and founded some solutions such as change 2.4.+ to 2.4.0 ! 我已经搜索并找到了一些解决方案,例如将2.4.+更改为2.4.0 or this link , but they didn`t solve the problem 此链接 ,但他们没有解决问题

The question is : 问题是 :

When a project imported, what should be same in imported build.gradle versions and my app build.gradle versions ?! 导入项目时,导入的build.gradle版本和我的应用程序build.gradle版本应该是什么?

My project compile in offline mode, Should I disable offline mode and let the Android Studio to download gradle files needed ? 我的项目以离线模式编译,是否应该禁用离线模式并让Android Studio下载所需的gradle文件?

As the link for the library says, do the following in the build.gradle. 正如该链接所述 ,在build.gradle中执行以下操作。 Copy the compile statement below in the dependencies tag. 将下面的compile语句复制到dependencies标记中。 Your library name was wrong. 您的库名称错误。

repositories {
    jcenter()
}

dependencies {
    compile 'com.github.navasmdc:MaterialDesign:1.5@aar'
}

You will find the dependencies in the build.gradle in the app folder not in the project folder. 您将在app文件夹而不是项目文件夹的build.gradle中找到依赖项。

You need to disable offline mode. 您需要禁用离线模式。 After the library is imported you can go back to offline mode. 导入库后,您可以返回离线模式。

About the cannot resolve error: nineoldandroid library is very old and now deprecated. 关于无法解决的错误: nineoldandroid库非常老,现在已弃用。 I believe the material design library is using NineoldAndroid library. 我相信材料设计库正在使用NineoldAndroid库。 For some reason, it not able download this library. 由于某种原因,它无法下载该库。 Why don't you add the nineoldandroid library first. 为什么不先添加nineoldandroid库。 If the material design library finds it then it may not try to download it. 如果材料设计库找到它,则它可能不会尝试下载它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM