关于java:Error:resource android:style / TextAppearance.Material.Widget.Button.Borderless.Colored找不到

Error:resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found

我正在尝试建立一个包含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

enter image description here

我是一名iOS开发人员,在Android方面没有太多经验,我无法找到此错误代码的位置以及解决方法。

编辑:1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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'
}


在API 24中添加了android:style / TextAppearance.Material.Widget.Button.Borderless.Colored,因此您不能在23版中使用它。可以使用在23版之前添加的样式。您还可以将新样式应用于较新版本的设备,并应用旧样式作为默认设置:https://developer.android.com/guide/topics/ui/look-and-feel/themes.html#Versions

添加了03/20 / '18 12:32

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

  • 可以在[something] /res/layout/xxx.xml中的布局文件中为某个TextView设置文本的外观,"布局"也可以是" layout-xxx"。
  • 可以在[something] /res/values/styles.xml中的样式文件中进行设置," values"也可以是" values-xxx"。
  • 可以在Android Studio的项目树中轻松找到" res"文件夹。
    您也可以使用Ctrl + Shift + F来搜索整个项目。
    找到后,只需删除或注释该行。


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

    解:

    在build.gradle中添加以下代码。
    将此放置在所有项目中{

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    // 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"
                    }
                }
        }
    }

    检查" style.xml"文件,您会看到错误突出显示。在以下更改应用程序主题颜色:

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