我尝试将我的HelloWorld应用程序全息主题更改为Material.Light.DarkActionBar主题(正如新的Android开发工具会话所述)。但我得到了以下错误。我尝试更改目标SDK版本为21.但我们在SDK Manager中没有21 SDK。在那次会议中,他们说,为v-21设置样式xml。
值/ styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
值-V21 / styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
的build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.ramapps.helloworld"
minSdkVersion 15
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
错误:
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light.DarkActionBar'.
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Applications/Android Studio.app/sdk/build-tools/android-4.4W/aapt package -f --no-crunch -I /Applications/Android Studio.app/sdk/platforms/android-20/android.jar -M /Users/Ram_PC/Ram/MyDrive/My_Workspaces/Android_Studio_Workspace_L/HelloWorld/app/build/intermediates/manifests/debug/AndroidManifest.xml -S /Users/Ram_PC/Ram/MyDrive/My_Workspaces/Android_Studio_Workspace_L/HelloWorld/app/build/intermediates/res/debug -A /Users/Ram_PC/Ram/MyDrive/My_Workspaces/Android_Studio_Workspace_L/HelloWorld/app/build/intermediates/assets/debug -m -J /Users/Ram_PC/Ram/MyDrive/My_Workspaces/Android_Studio_Workspace_L/HelloWorld/app/build/generated/source/r/debug -F /Users/Ram_PC/Ram/MyDrive/My_Workspaces/Android_Studio_Workspace_L/HelloWorld/app/build/intermediates/libs/app-debug.ap_ --debug-mode --custom-package com.ramapps.helloworld -0 apk
Error Code:
1
Output:
/Users/Ram_PC/Ram/MyDrive/My_Workspaces/Android_Studio_Workspace_L/HelloWorld/app/build/intermediates/res/debug/values-v21/values.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light.DarkActionBar'.
答案 0 :(得分:29)
您可以尝试像这样设置build.gradle
中的值(针对API 25更新):
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 21 //oldest version you would like to support
targetSdkVersion 25
versionCode 1
versionName "1.0"
...
}
}
答案 1 :(得分:8)
我们无法在除L设备之外的任何设备上安装以L Preview为目标的应用。
将res/values/styles.xml
,Theme.Material.Light
更改为Theme.Light
,然后将build.gradle
更改为我。
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
applicationId 'com.example.android.market.licensing'
minSdkVersion 13
targetSdkVersion 20
versionCode 1
versionName '1.0'
}
虽然Theme.Material.Light
是20sdk版本的一部分,但不知何故它对我不起作用。
答案 2 :(得分:3)
从AssemblyMenifest.xml将应用程序的目标设置为API级别21,或将<uses-sdk android:targetSdkVersion="21" android:minSdkVersion="19" />
标记添加到AssemblyMenifest.xml
答案 3 :(得分:2)
我将 Theme.Material.Light 更改为 Theme.Light ,这对我有用。
答案 4 :(得分:1)
我认为这里的问题是您需要将buildToolsVersion
设置为Android L之前的版本。
这是我的gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.mayuonline.ribbit"
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile 'com.android.support:support-v13:19.+'
}
另请务必更改styles.xml
,如下所示
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme.Light">
</style>
</resources>
这应解决问题。