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

时间:2014-12-23 16:41:30

标签: java android xml android-support-library cardslib

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

G:\UI Kit\Android Sample Projects\cardslib-master\cardslib-master\library-cards\src\main\res\values\styles.xml:23: error: Error retrieving parent for item: No resource found that matches the given name 'card.native'.
    G:\UI Kit\Android Sample Projects\cardslib-master\cardslib-master\library-cards\src\main\res\values-v16\styles.xml:22: error: Error retrieving parent for item: No resource found that matches the given name 'card.native'.
    G:\UI Kit\Android Sample Projects\cardslib-master\cardslib-master\library-cards\src\main\res\values-v16\styles.xml:23: error: Error: No resource found that matches the given name: attr 'android:fontFamily'.
     G:\UI Kit\Android Sample Projects\cardslib-master\cardslib-master\library-cards\src\main\res\values\styles.xml:34: error: Error retrieving parent for item: No resource found that matches the given name 'card.native.content_outer_layout'.
    G:\UI Kit\Android Sample Projects\cardslib-master\cardslib-master\library-cards\src\main\res\values\styles.xml:48: error: Error retrieving parent for item: No resource found that matches the given name 'card.native'.
    G:\UI Kit\Android Sample Projects\cardslib-master\cardslib-master\library-cards\src\main\res\values\styles.xml:55: error: Error retrieving parent for item: No resource found that matches the given name 'card.native'.

    G:\UI Kit\Android Sample Projects\cardslib-master\cardslib-master\library-cards\src\main\res\values\styles.xml:64: error: Error retrieving parent for item: No resource found that matches the given name 'card.native'.

    G:\UI Kit\Android Sample Projects\cardslib-master\cardslib-master\library-cards\src\main\res\values\styles.xml:23: error: Error retrieving parent for item: No resource found that matches the given name 'card.native'.

    G:\UI Kit\Android Sample Projects\cardslib-master\cardslib-master\library-cards\src\main\res\values-v16\styles.xml:22: error: Error retrieving parent for item: No resource found that matches the given name 'card.native'.

    G:\UI Kit\Android Sample Projects\cardslib-master\cardslib-master\library-cards\src\main\res\values\styles.xml:34: error: Error retrieving parent for item: No resource found that matches the given name 'card.native.content_outer_layout'.

    G:\UI Kit\Android Sample Projects\cardslib-master\cardslib-master\library-cards\src\main\res\values\styles.xml:48: error: Error retrieving parent for item: No resource found that matches the given name 'card.native'.

    G:\UI Kit\Android Sample Projects\cardslib-master\cardslib-master\library-cards\src\main\res\values\styles.xml:55: error: Error retrieving parent for item: No resource found that matches the given name 'card.native'.
     G:\UI Kit\Android Sample Projects\cardslib-master\cardslib-master\library-cards\src\main\res\values\styles.xml:64: error: Error retrieving parent for item: No resource found that matches the given name 'card.native'.

我尝试将库的Build目标更改为Android 5.0,但这没有帮助。你能提出什么建议?

1 个答案:

答案 0 :(得分:0)

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

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

  • 图书馆的目标是21(而不是14)
  • minSdk是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'
}