【问题标题】:Error:resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found错误:资源 android:style/TextAppearance.Material.Widget.Button.Borderless.Colored 未找到
【发布时间】:2018-03-17 00:52:33
【问题描述】:

我正在尝试构建一个具有 compileSdkVersion 25 和 targetSdkVersion 25 的项目,但我需要将两者都更改为 23,因此在更改 compileSdkVersion 23 和 targetSdkVersion 23 后出现错误

错误:资源 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 失败

我是一名 iOS 开发人员,在 Android 方面没有太多经验,我无法在代码中找到此错误点以及如何修复。

编辑: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.jackson.core.ObjectCodec'
        exclude 'META-INF/services/com.fasterxml.jackson.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'
}

【问题讨论】:

标签: java android


【解决方案1】:

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

添加 03/20/'18 12:32

由于您不熟悉 Android,一个简单的解决方案是使用较旧的文本外观。这至少使该应用程序可以在您的 Android 5 设备上运行。之后您可以了解如何进一步自定义 TextView,但现在让我们让它工作。

  1. 可以为布局文件中的某个 TextView 设置文本的外观,该文件位于 [something]/res/layout/xxx.xml,“布局”也可以是“布局-xxx”。
  2. 它可以在样式文件中设置,位于 [something]/res/values/styles.xml,“values”也可以是“values-xxx”。

可以从 Android Studio 的项目树中轻松找到文件夹“res”。
您也可以使用 Ctrl+Shift+F 在整个项目中进行搜索。
当你找到它时,只需删除或评论该行。

【讨论】:

  • 是的,我也想到了,但问题是如何找到它写的代码,因为我不知道代码不是我写的。
  • 能不能发一下build.gradle..,检查支持库的版本,一般都得用同一个版本
  • 编辑问题并添加 build.gradle
  • 即使我使用的是 28,我也遇到了这个问题。
  • 带有compileSdkVersion 和Android 支持库版本(v4 和v7 的东西)都在api 24 以上?
【解决方案2】:

问题: android 26 或更高版本支持 colorError 并且此包在 23 上,但是该包可能在较低版本中。

解决方案:

在 build.gradle 中添加以下代码。 把它放在所有项目中{

// 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"
                }
            }
    }
}

【讨论】:

  • 这是唯一有效的答案,因为错误是由依赖项引发的。谢谢!
【解决方案3】:

检查“style.xml”文件,您会看到错误已突出显示。更改应用主题颜色如下:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

【讨论】:

    猜你喜欢
    • 2018-11-07
    • 1970-01-01
    • 2016-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多