java - 如何将 appcompat-v7 与 android API 19 一起使用

标签 java android compatibility android-5.0-lollipop android-appcompat

一切都在问题中

我有一个带有这个 gradle 的模块:

apply plugin: 'com.android.library'
android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"
    compileOptions.encoding "ISO-8859-1"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 8
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:21.0.3'
}

当我将“compileSdkVersion”更改为 19 => 我收到 100 多个关于未找到资源的错误:

示例:

    Error:(9, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body1'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body2'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Button'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Caption'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display1'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display2'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display3'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display4'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Headline'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Inverse'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Large'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Large.Inverse'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Large'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Small'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Medium'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Medium.Inverse'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Menu'.
Error:Error retrieving parent for item: No resource found that matches the given name '@android:TextAppearance.Material.SearchResult.Subtitle'.
Error:Error retrieving parent for item: No resource found that matches the given name '@android:TextAppearance.Material.SearchResult.Title'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Small'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Small.Inverse'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Subhead'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Title'.

最佳答案

当然你会在 API<21 中遇到这些错误,因为 android:TextAppearance.Material 和其他(Material)是在 API 21 中引入的。AppCompat 正在移植资源,但它们没有使用 android: 前缀(我目前无法检查您是否也在使用这些前缀,但可能是)。如果您使用 API 21 编译您的应用程序并在较低的 API 上运行,设备崩溃也会发生

android: 前缀指的是内置参数,它应该在所有版本的支持的 APIs (minSDK) 中。 API21 之前的系统中不存在 Material

关于java - 如何将 appcompat-v7 与 android API 19 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28149017/

相关文章:

java - 如何使用一个对象中的多个属性并将其映射到另一个对象中的单个属性?

Java IO - 输出文件的大小大于原始文件

java - 自定义数组列表按位置更改项目

java - admob 智能横幅需要位于应用程序底部(通过 java)

javascript - 在 Android 上的 PhoneGap 3.3 系统浏览器中打开链接

.net - 带有.NET库的VB6

java - 罗马数字和正则表达式

Java 在 swing/awt 中制作一个 'dot/pixel'

ios - 仅为 iOS 7 提供更新

excel - vbNewline 与 Chr(10) 作为 Windows 与 Mac OSX 中的换行分隔符