几个 android 属性未在 styles.xml 中解析

Several android attributes not resolved in styles.xml

下面我的 styles.xml 中以 "android:" 开头的每个属性都给我一个 "cannot resolve symbol" 错误。这种情况已经有一段时间了,所以我不确定它是从哪里开始的,是什么原因造成的。删除 "android:" 会在构建日志中出现 "resource linking failed" 错误。

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

<style name="TheoTheme" parent="AppTheme">
    <item name="colorAccent">@color/Accent</item>
    <item name="android:colorBackground">@color/lightBackground</item>
</style>

<style name="TheoTheme.ActionBarReverse" parent="TheoTheme">
    <item name="android:textColorPrimary">@color/text_color_primary</item>
</style>

<style name="PurpleTheme" parent="TheoTheme">
    <item name="colorAccent">@color/Accent2</item>
</style>

<style name="ChatRoomTheme" parent="TheoTheme">
    <item name="colorAccent">@color/Accent</item>
</style>

<style name="LoginTheme" parent="TheoTheme" >
    <item name="android:colorBackground">@color/colorPrimary</item>
</style>

<style name="RegisterTheme" parent="TheoTheme">
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="FirebaseUI.AuthMethodPicker.Logo">
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="gravity">center</item>

</style>

<style name="GenericProgressBackground" parent="android:Theme">
    <item name="android:layout_width">fill_parent</item>
    <item name="android:layout_height">fill_parent</item>
    <item name="android:background">@color/colorPrimaryDark</item>
    <item name="android:gravity">center</item>
</style>
<style name="GenericProgressIndicator" parent="@android:style/Widget.ProgressBar">
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:indeterminate">true</item>
</style>

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

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

<style name="DMTheme.AppTheme" parent="ChatRoomTheme" />

build.gradle 文件:

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    signingConfigs {
        ReleaseKey {
            file('X:\Documents\All\Creative\Programming\Projects\KeyStore\TheoKeyStore.jks')

        }
    }
    compileSdkVersion 28
    defaultConfig {
        applicationId "app.meettheo.theo"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 5
        versionName "0.1"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.ReleaseKey
        }
        debug {
            signingConfig signingConfigs.ReleaseKey
        }
    }
    lintOptions {
        checkReleaseBuilds false
    }
}



dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:support-v13:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:customtabs:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:support-media-compat:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'android.arch.paging:runtime:1.0.1'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'org.jetbrains:annotations:16.0.2'
    implementation 'com.google.android.gms:play-services-auth:16.0.1'
    implementation 'com.google.android.gms:play-services-ads:17.0.0'
    implementation 'com.google.android.gms:play-services-places:16.0.0'
    implementation 'com.google.android.gms:play-services-maps:16.0.0'
    implementation 'com.facebook.android:facebook-android-sdk:4.38.1'
    implementation 'com.google.firebase:firebase-core:16.0.4'
    implementation 'com.firebaseui:firebase-ui-auth:4.2.0'
    implementation 'com.google.firebase:firebase-firestore:17.1.3'
    implementation 'com.firebaseui:firebase-ui-firestore:4.1.0'
    implementation 'com.google.firebase:firebase-auth:16.0.5'
    implementation 'com.google.firebase:firebase-ads:17.0.0'
    implementation 'com.google.firebase:firebase-messaging:17.3.4'
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.6@aar') {
        transitive = true
    }
}


apply plugin: 'com.google.gms.google-services'

Invalidating/cleaning/rebuilding 不起作用。我打破了什么让这发生?

转到您的 gradle,注释掉您正在使用的支持库,同步您的项目,您将收到错误。然后取消注释库并再次同步。现在项目将成功构建,您的问题很可能会得到解决。我不确定这是怎么引起的,但上面的解决方案在过去对我有用 caches/clean/rebuilt 会失败。

编辑:还取决于 属性 您可能想要添加应用程序:而不是 android:

我遇到这个问题已经有一段时间了,这也让我很生气。

猜猜解决方案是什么?就像通过 File -> Open:

重新导入项目一样简单

此后所有资源都被正确解析。

我认为您可以尝试以下解决方案:

  • 备份项目
  • 删除.idea文件夹和.i​​ml文件
  • 重新启动 Android Studio 并重新导入项目。

对于某些人来说,只需从 .idea 文件夹中删除所有库并重新同步即可 Gradle。

如果其中 none 个正常工作,您总是可以重新安装完整的工作室,这取决于您的网络速度,不会花费那么长时间。