【发布时间】:2016-01-11 03:28:24
【问题描述】:
我正在尝试使用 android studio 将 Android API 从 23 降低到 16,但在项目运行时出现错误。我已经安装了 sdk 版本 18。
之前
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.project.myapplication"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
}
之后
apply plugin: 'com.android.application'
android {
compileSdkVersion 16
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.project.myapplication"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
}
错误
Error:(231, 62) error: diamond operator is not supported in -source 1.6
(use -source 7 or higher to enable diamond operator)
清理项目后
C:\Users\tongws\AndroidStudioProjects\MyApplication1\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.0\res\values-ldltr-v21\values-ldltr-v21.xml
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner.Underlined'.
C:\Users\tongws\AndroidStudioProjects\MyApplication1\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.0\res\values-ldrtl-v23\values-ldrtl-v23.xml
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner.Underlined'.
C:\Users\tongws\AndroidStudioProjects\MyApplication1\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.0\res\values-v17\values-v17.xml
C:\Users\tongws\AndroidStudioProjects\MyApplication1\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.0\res\values-v21\values-v21.xml
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Medium.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Large.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Small.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ProgressBar'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ProgressBar.Horizontal'.
谁能告诉我如何解决这个问题?
【问题讨论】:
-
你试过清理和构建吗?
-
请注意best practice for compileSdkVerison 始终使用最新的 SDK 进行编译,即使您想针对较低的 SDK。
标签: android api android-studio gradle build