Android:添加一个具有不同 Android Target API 的库



所以我找到了这个库:CardsLib,这是一个非常现代和酷炫的界面,可以在Android中实现,我按照他在这里给出的说明将库添加到我的项目中。但是,我的主要项目具有Android 5.0(21(的构建目标API,而Cardslib库的目标为Android 4.0(14(,当添加到我的项目中时,会给我留下一个令人讨厌的错误列表,如下所示:

G:UI KitAndroid Sample Projectscardslib-mastercardslib-masterlibrary-cardssrcmainresvaluesstyles.xml:23: error: Error retrieving parent for item: No resource found that matches the given name 'card.native'.
    G:UI KitAndroid Sample Projectscardslib-mastercardslib-masterlibrary-cardssrcmainresvalues-v16styles.xml:22: error: Error retrieving parent for item: No resource found that matches the given name 'card.native'.
    G:UI KitAndroid Sample Projectscardslib-mastercardslib-masterlibrary-cardssrcmainresvalues-v16styles.xml:23: error: Error: No resource found that matches the given name: attr 'android:fontFamily'.
     G:UI KitAndroid Sample Projectscardslib-mastercardslib-masterlibrary-cardssrcmainresvaluesstyles.xml:34: error: Error retrieving parent for item: No resource found that matches the given name 'card.native.content_outer_layout'.
    G:UI KitAndroid Sample Projectscardslib-mastercardslib-masterlibrary-cardssrcmainresvaluesstyles.xml:48: error: Error retrieving parent for item: No resource found that matches the given name 'card.native'.
    G:UI KitAndroid Sample Projectscardslib-mastercardslib-masterlibrary-cardssrcmainresvaluesstyles.xml:55: error: Error retrieving parent for item: No resource found that matches the given name 'card.native'.
    G:UI KitAndroid Sample Projectscardslib-mastercardslib-masterlibrary-cardssrcmainresvaluesstyles.xml:64: error: Error retrieving parent for item: No resource found that matches the given name 'card.native'.
    G:UI KitAndroid Sample Projectscardslib-mastercardslib-masterlibrary-cardssrcmainresvaluesstyles.xml:23: error: Error retrieving parent for item: No resource found that matches the given name 'card.native'.
    G:UI KitAndroid Sample Projectscardslib-mastercardslib-masterlibrary-cardssrcmainresvalues-v16styles.xml:22: error: Error retrieving parent for item: No resource found that matches the given name 'card.native'.
    G:UI KitAndroid Sample Projectscardslib-mastercardslib-masterlibrary-cardssrcmainresvaluesstyles.xml:34: error: Error retrieving parent for item: No resource found that matches the given name 'card.native.content_outer_layout'.
    G:UI KitAndroid Sample Projectscardslib-mastercardslib-masterlibrary-cardssrcmainresvaluesstyles.xml:48: error: Error retrieving parent for item: No resource found that matches the given name 'card.native'.
    G:UI KitAndroid Sample Projectscardslib-mastercardslib-masterlibrary-cardssrcmainresvaluesstyles.xml:55: error: Error retrieving parent for item: No resource found that matches the given name 'card.native'.
     G:UI KitAndroid Sample Projectscardslib-mastercardslib-masterlibrary-cardssrcmainresvaluesstyles.xml:64: error: Error retrieving parent for item: No resource found that matches the given name 'card.native'.

我尝试将库的构建目标更改为 Android 5.0,但这没有帮助。请问你们有什么建议?

首先,你可以在这里查看关于target、minSdk和api的所有信息:

https://github.com/gabrielemariotti/cardslib/blob/master/library-core/build.gradle

  • 库的目标是 21(而不是 14(
  • 最小Sdk是14
  • 编译所需的 API 是 21
现在,很难

说出您的问题是什么,但是此错误

No resource found that matches the given name: attr 'android:fontFamily'

听起来您正在使用 API<16 来编译您的项目。

第二个建议是使用Android Studio(现在是官方IDE(与Android和这个库一起工作。

只需将此行添加到依赖项中即可

dependencies {
    //Core card library
    compile 'com.github.gabrielemariotti.cards:cardslib-core:2.0.1'
}

最新更新