我的Android应用程序对此build.gradle文件没有任何问题.
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsversion "23.0.1"
defaultConfig {
applicationId "com.marshall.opensurvey"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
jcenter()
}
dependencies {
compile filetree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:support-annotations:23.1.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:support-v13:23.1.0'
compile 'com.squareup.okhttp:okhttp:2.0.0'
// Material Drawer Library by Mike Penz
compile('com.mikepenz:materialdrawer:4.3.9@aar') {
transitive = true
}
// Android Iconics Library by Mike Penz
compile 'com.mikepenz:iconics-core:1.7.9@aar'
compile 'com.mikepenz:google-material-typeface:1.2.0.1@aar'
// Google Analytics Library
compile 'com.google.android.gms:play-services-analytics:8.1.0'
// Circle Image View Library
compile 'de.hdodenhof:circleimageview:2.0.0'
// Flat Button Library
compile 'info.hoang8f:fbutton:1.0.5'
// Process Button Library
compile 'com.github.dmytrodanylyk.android-process-button:library:1.0.4'
// Fancy Button Library
compile 'com.github.medyo:fancybuttons:1.5@aar'
// Card View and Recycler View Library
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
}
但是,当我在build.gradle文件中添加另一个依赖项并同步时,它开始显示错误,说已经定义了属性’rippleColor’.我放在gradle文件中的新依赖是这个.
// Material Design Library
compile 'com.github.navasmdc:MaterialDesign:1.5@aar'
我假设显示此错误是因为新添加的错误包含的属性与先前添加的库中已定义的名称相同.我应该在这个文件中修改什么,以便第三方库不会相互崩溃?
解决方法:
问题是MaterialDesign库没有为其属性添加前缀.
属性在attrs.xml中定义,您必须将rippleColor属性重命名为其他属性.
这里的一个好建议是为该库特定的所有属性加前缀,这样就不会与其他库冲突.
所以它看起来像这样
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="CustomAttributes">
<!-- Color of ripple animation -->
<attr name="mdl_rippleColor" format="color|reference" />
<!-- You can also prefix all other attributes -->
</declare-styleable>
</resources>
之后,您必须在MaterialDesign库的代码中找到所有这些,并为它们添加前缀,以便可以通过编程方式读取这些属性.一个是在LayoutRipple (Line: 56)班.
看来这个图书馆不再被积极维护了.大约200个未解决的问题和30个拉取请求.
为了简化一切,我修改并修复了源代码(我还更新到最新的v23.1.0支持库)并将其上传到SNAPSHOT maven中央存储库.您可以通过执行以下两个步骤来使用它:
将SNAPSHOT maven存储库添加到root build.gradle
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
如下图所示:SNAPSHOT maven repository
将依赖项添加到build.gradle
compile 'com.mikepenz.thirdparty:material-design-library:1.5.0-SNAPSHOT'
Here’s the link to the SNAPSHOT *.aar.
maven组是不同的,因为我不允许与原始maven组一起托管它.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。