问题
Every attribute prefaced by "android:" in my styles.xml below is giving me a "cannot resolve symbol" error. It's been like this for a while so I'm not sure where it began and what causes it. Removing "android:" gives me a "resource linking failed" error in the build log.
<!-- 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 file:
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 does not work. What did I break to make this happen?
回答1:
I think you could try the following solution:
- Back up project
- Delete the .idea folder and .iml files
- Relaunch Android Studio and re-import the project.
For some people it will work to just remove all the libraries from .idea folder and re-sync Gradle.
If none of these are working you always could reinstall the complete studio which, depending on your network speed, wouldn't take that long.
回答2:
go to your gradle, comment out the support libraries you're using, sync your project and you will get errors. Then uncomment the libraries and sync again. Now the project will be successfully built, and chances are your problem will be resolved. I'm not sure how this is caused in the first place, but the above solution has worked for me in the past when caches/clean/rebuilt would fail.
Edit: Also depending on the property you might want to add app: instead of android:
回答3:
I've had that issue for some time and that also pissed me off.
Guess what's the solution? As simple as re-importing the project again via File -> Open
:
Thereafter all of the resources were correctly resolved.
来源:https://stackoverflow.com/questions/53660829/several-android-attributes-not-resolved-in-styles-xml