Gradle build error style attributes not found

Viewed 35068

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
}
4 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

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.

If you use a theme style with parent="android:Theme.DeviceDefault", you should use

<item name="android:windowActionBar">false</item>

instead of

<item name="windowActionBar">false</item>

Or change the theme style from "android:Theme.DeviceDefault" to "Theme.AppCompat.Light.DarkActionBar", it also may resolves some other style problems.

Related