Java 如何将appcompat-v7与android API 19一起使用
一切都在问题中 我有一个带有这个刻度的模块:Java 如何将appcompat-v7与android API 19一起使用,java,android,compatibility,android-5.0-lollipop,android-appcompat,Java,Android,Compatibility,Android 5.0 Lollipop,Android Appcompat,一切都在问题中 我有一个带有这个刻度的模块: apply plugin: 'com.android.library' android { compileSdkVersion 21 buildToolsVersion "21.1.2" compileOptions.encoding "ISO-8859-1" defaultConfig { minSdkVersion 8 targetSdkVersion 8 } b
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中会遇到这些错误,请检查build.gradle中的compileSdkVersion 例如
如果你保持最新,就不会让你头疼。发生这种情况的原因是,如果为同一个库生成了多个R文件 试试这个
compile'com.android.support:appcompat-v7:19.+'
targetSdkVersion不应该是8,这真的很糟糕。这是一个库模块,我可以使用targetSdkVersion,我想我个人使用md-answer已经很久了。换句话说,我们的minsdk至少应该是API 21吗?不,使用要支持的最小sdk版本。但是,如果您想使用更新SDK中的任何新方法/类/样式(如上所述),请记住,在具有较旧Android版本的设备上(如支持的最旧minSdk)的应用程序可能会抛出异常
,或者干脆忽略这些行(例如XML文件中的attr)。上面的问题是关于AppCompat
库的,它为您的应用程序带来了一些来自较新sdk的方法/类/样式,因此新样式(材质,部分)也可能用于较旧的系统(例如ICS),但请注意,它们具有不同的命名,这不会干扰原始名称
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
dexOptions {
javaMaxHeapSize "2g"
//jumboMode true
}
}