Java 错误:资源 android:style/TextAppearance.Material.Widget.Button.Borderless.Colored 未找到
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49331411/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error:resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found
提问by Varun Naharia
I am trying to build a project that has compileSdkVersion 25 and targetSdkVersion 25 but I need to change both to 23 so after changing compileSdkVersion 23 and targetSdkVersion 23 I am getting an error
我正在尝试构建一个具有 compileSdkVersion 25 和 targetSdkVersion 25 的项目,但我需要将两者都更改为 23,因此在更改 compileSdkVersion 23 和 targetSdkVersion 23 后,出现错误
Error:resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found. Error:resource android:style/TextAppearance.Material.Widget.Button.Colored not found. Error:failed linking references. Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details Error:Execution failed for task ':app:processDebugResources'.
Failed to execute aapt
错误:资源 android:style/TextAppearance.Material.Widget.Button.Borderless.Colored 未找到。错误:资源 android:style/TextAppearance.Material.Widget.Button.Colored 未找到。错误:链接引用失败。错误:java.util.concurrent.ExecutionException:java.util.concurrent.ExecutionException:com.android.tools.aapt2.Aapt2Exception:AAPT2 错误:检查日志以获取详细信息错误:java.util.concurrent.ExecutionException:com.android.tools .aapt2.Aapt2Exception:AAPT2 错误:检查日志以获取详细信息错误:com.android.tools.aapt2.Aapt2Exception:AAPT2 错误:检查日志以获取详细信息错误:任务“:app:processDebugResources”的执行失败。
执行 aapt 失败
I am an iOS developer and doesn't have much experience in Android, I am unable to find where this error point in code and how to fix.
我是一名 iOS 开发人员,在 Android 方面没有太多经验,我无法在代码中找到此错误点以及如何修复。
Edit: 1
编辑:1
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '26.0.2'
defaultConfig {
applicationId 'com.abc.app'
minSdkVersion 21
targetSdkVersion 23
versionCode 4
versionName '1.3'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
buildConfigField("String", "API_KEY", "\"empty\"")
//buildConfigField("String", "API_KEY", API_KEY)
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/services/com.fasterxml.Hymanson.core.ObjectCodec'
exclude 'META-INF/services/com.fasterxml.Hymanson.core.JsonFactory'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.wang.avi:library:2.1.3'
implementation 'com.android.support:appcompat-v7:25.4.0'
implementation 'com.android.support:customtabs:25.4.0'
implementation 'com.android.support:cardview-v7:25.4.0'
implementation 'com.nex3z:toggle-button-group:1.1.2'
implementation 'com.github.ivbaranov:materialfavoritebutton:0.1.4'
implementation 'com.android.support:design:25.4.0'
implementation 'com.android.volley:volley:1.0.0'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.2'
implementation 'com.yqritc:recyclerview-flexibledivider:1.2.9'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.google.code.gson:gson:2.8.1'
implementation 'com.github.bumptech.glide:glide:4.3.1'
implementation 'com.google.android.gms:play-services-ads:11.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.3.1'
implementation('com.github.fcopardo:easyrest:v1.4.2@aar') {
transitive = true
}
// compile 'com.github.wrdlbrnft:sorted-list-adapter:0.3.0.27'
testImplementation 'junit:junit:4.12'
}
回答by Meow Cat 2012
android:style/TextAppearance.Material.Widget.Button.Borderless.Colored was added in API 24 so you can't use it with version 23. You can use a style that was added before version 23. You can also apply new styles to newer-versioned devices and apply an old style as a default: https://developer.android.com/guide/topics/ui/look-and-feel/themes.html#Versions
android:style/TextAppearance.Material.Widget.Button.Borderless.Colored 是在 API 24 中添加的,所以你不能在版本 23 中使用它。你可以使用版本 23 之前添加的样式。你也可以应用新样式到更新版本的设备并默认应用旧样式:https: //developer.android.com/guide/topics/ui/look-and-feel/themes.html#Versions
Added03/20/'18 12:32
添加03/20/'18 12:32
As you're not familiar with Android, a simple solution is to just use an older text appearance. This at least makes the app working on your Android 5 device. Afterwards you can learn about how to further customize the TextView, but for now let's just make it work.
由于您不熟悉 Android,一个简单的解决方案是使用较旧的文本外观。这至少可以使应用程序在您的 Android 5 设备上运行。之后您可以了解如何进一步自定义 TextView,但现在让我们让它工作。
- The appearance of text may be set for a certain TextView within a layout file, located at [something]/res/layout/xxx.xml, which the "layout" could also be "layout-xxx".
- It may be set within a style file, located at [something]/res/values/styles.xml, "values" may also be "values-xxx".
- 可以为布局文件中的某个TextView 设置文本的外观,位于[something]/res/layout/xxx.xml,其中“layout”也可以是“layout-xxx”。
- 它可以在位于 [something]/res/values/styles.xml 的样式文件中设置,“values”也可以是“values-xxx”。
folder "res" can be easily found from the project tree in Android Studio.
You can also use Ctrl+Shift+Fto search in whole project.
When you find it, just delete or comment the line.
可以从 Android Studio 的项目树中轻松找到文件夹“res”。
您也可以使用Ctrl+Shift+F在整个项目中进行搜索。
找到后,只需删除或注释该行即可。
回答by hoor shin haye
Check "style.xml" file & you see errors are highlighted. Change App theme color in following:
检查“style.xml”文件,您会看到错误突出显示。在以下更改应用主题颜色:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
回答by Gowthaman
Issue:The colorError is supported in android 26 or higher and this package is on 23, However the package might be in the lower version.
问题:android 26 或更高版本支持 colorError,此包在 23 上,但是包可能是较低版本。
Solution:
解决方案:
Add the following code in build.gradle. place this inside allprojects {
在 build.gradle 中添加以下代码。把它放在 allprojects {
// force libs to use recent buildtools
// https://github.com/luggit/react-native-config/issues/299
subprojects {
afterEvaluate {
project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion = 27
buildToolsVersion = "27.0.3"
}
}
}
}