29
votes

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

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

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.

Edit: 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'
}
3
Why did you want to change to version 23 ? - ישו אוהב אותך
I tried various workarounds but only this one helped me. - Vladimir Vlasov
if you are here because of a react-native project please check [ this](stackoverflow.com/questions/50574492/…) - Navneet kumar
The DJI UX SDK requires >= 24 due to this issue. But because the included ffmpeg 0x86 library cannot deal with an SDK > 23 this will not compile. Apparently the DJI UX SDK needs a rewrite and the supported mpeg lib needs an upgrade. - SChalice

3 Answers

19
votes

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

Added 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.

  1. 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".
  2. It may be set within a style file, located at [something]/res/values/styles.xml, "values" may also be "values-xxx".

folder "res" can be easily found from the project tree in Android Studio.
You can also use Ctrl+Shift+F to search in whole project.
When you find it, just delete or comment the line.

8
votes

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.

Solution:

Add the following code in build.gradle. place this inside 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"
                }
            }
    }
}
1
votes

Check "style.xml" file & you see errors are highlighted. Change App theme color in following:

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