Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle build error style attributes not found

I was trying to roll my project back to a previous version by checking the git out from GitHub, but I think I did it in a wrong way. I just removed the local project and checked out the git address on android studio. However, the gradle can't build and shows this message:

I navigate to the line that is saying style attr not found, and select find usage, but it says no usage in this project. I also tried removed the twitter tool kits and load it again, and load an older verision, both still have this issue. How to fix this? gradle build wrong

The project is build with android studio 3.0 canary from beginning. this is the app gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "..."
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 3
        versionName "beta1"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    testCompile 'junit:junit:4.12'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:support-v4:26.0.0'
    compile 'com.android.support:recyclerview-v7:26.0.0'
    compile 'com.twitter.sdk.android:twitter:3.1.0'
    compile 'com.jakewharton:butterknife:8.7.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.8.1'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    annotationProcessor 'com.github.bumptech.glide:glide:3.7.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'
    implementation 'com.android.support:appcompat-v7:26.0.0'
    implementation 'com.android.support:design:26.0.0'
}

And another build file:

buildscript {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-alpha9'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
like image 897
Robin Avatar asked Aug 09 '17 00:08

Robin


3 Answers

Adding Preference Support Library v7 dependency to Gradle solved a problem for me. It supports missed attributes for @style/PreferenceThemeOverlay.

Put the following line to your build.gradle module:

com.android.support:preference-v7:27.1.1

like image 66
Andrii Artamonov Avatar answered Nov 20 '22 20:11

Andrii Artamonov


That is a problem with themes and styles. Probably one of your libraries is expecting that style to be available and it's not finding it. See here Cant set Android Actionbar Background correctly as a guide on how to fill in that particular attribute that may work for you.

This resource seems to have been introduced in 2013 according to google's diffs here https://android.googlesource.com/platform/tools/base/+/f5215ae4712f468568b58c20baadd14b769c10c4%5E!/

Changing your themes.xml followed by using it from the manifest, or changing styles.xml can potentially cause those side effects if not done properly.

like image 33
Fabio Avatar answered Nov 20 '22 21:11

Fabio


2020 UPDATE: Unfortunately, it seems they haven't fix this issue yet, so the solution is to simple downgrade gradle version. For example, change it from:

classpath 'com.android.tools.build:gradle:3.6.3'

to

classpath 'com.android.tools.build:gradle:3.5.1'

and it will work.

like image 2
akelec Avatar answered Nov 20 '22 21:11

akelec