简体   繁体   English

找不到 Gradle 构建错误样式属性

[英]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.我试图通过从 GitHub 中检出 git 来将我的项目回滚到以前的版本,但我认为我以错误的方式做这件事。 I just removed the local project and checked out the git address on android studio.我刚刚删除了本地项目并查看了android studio上的git地址。 However, the gradle can't build and shows this message:但是,gradle 无法构建并显示此消息:

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.我还尝试删除了 twitter 工具包并重新加载它,并加载一个旧版本,两者仍然存在此问题。 How to fix this?如何解决这个问题? gradle 构建错误

The project is build with android studio 3.0 canary from beginning.该项目从一开始就使用 android studio 3.0 canary 构建。 this is the app gradle file:这是应用程序 gradle 文件:

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
}

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.请参阅此处无法正确设置 Android 操作栏背景作为如何填写可能适合您的特定属性的指南。

This resource seems to have been introduced in 2013 according to google's diffs here https://android.googlesource.com/platform/tools/base/+/f5215ae4712f468568b58c20baadd14b769c10c4%5E!/根据谷歌在此处的差异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.更改您的 themes.xml 然后从清单中使用它,或者更改 style.xml 如果操作不当可能会导致这些副作用。

Adding Preference Support Library v7 dependency to Gradle solved a problem for me.向 Gradle 添加 Preference Support Library v7 依赖项为我解决了一个问题。 It supports missed attributes for @style/PreferenceThemeOverlay.它支持@style/PreferenceThemeOverlay 的缺失属性。

Put the following line to your build.gradle module:将以下行放入您的 build.gradle 模块:

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. 2020 更新:不幸的是,他们似乎还没有解决这个问题,所以解决方案是简单地降级 gradle 版本。 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如果您使用带有 parent="android:Theme.DeviceDefault" 的主题样式,则应使用

<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.或者将主题样式从“android:Theme.DeviceDefault”改为“Theme.AppCompat.Light.DarkActionBar”,也可以解决一些其他的样式问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未找到 Gradle 构建错误样式属性 - Gradle build error styles attributes not found Gradle build:找不到文件错误 - Gradle build: file not found error 无法让Gradle构建Android L“错误:发现项目Style / AppTheme超过一次” - Trouble getting Gradle to build Android L “Error: Found item Style/AppTheme more than one time” Gradle 错误:创建构建时冲突属性 - Gradle Error: Colliding Attributes when creating Build Gradle 错误:统一 android 构建中的冲突属性 - Gradle Error: Colliding attributes in unity android build Gradle 构建:找不到资源 android:style/TextAppearance.Material - Gradle build: resource android:style/TextAppearance.Material not found 使用AAR的gradle构建失败,找不到资源错误 - gradle build with AAR failed with No resource found error Android gradle build错误:(9,0)未找到Gradle DSL方法:'compile()'。 - Android gradle build Error:(9, 0) Gradle DSL method not found: 'compile()'. Android Gradle构建错误:(10,0)未找到Gradle DSL方法:“ compile()” - Android gradle build Error:(10, 0) Gradle DSL method not found: 'compile()' Android Gradle构建错误:(65,0)未找到Gradle DSL方法:“ compile()” - Android gradle build Error:(65, 0) Gradle DSL method not found: 'compile()'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM