如何修复Android Studio中的“无法解析符号'app'”?

时间:2019-04-17 10:08:05

标签: java android appcompat-v7

Android Studio在与支持库相关的每一行上均显示错误。并在重建项目时说:

Android资源链接失败。

我尝试了以下操作:

  1. 清理/重建

  2. 入侵缓存/重新启动

  3. 卸载/重新安装Android Studio

我的build.gradle(app)正在关注:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.androphobia.fyp.spreadknowledge"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    buildToolsVersion '28.0.3'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.firebase:firebase-auth:16.1.0'
    implementation 'com.google.firebase:firebase-core:16.0.7'
    implementation 'com.google.firebase:firebase-storage:16.1.0'
    implementation 'com.google.firebase:firebase-firestore:18.0.1'
    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 'com.android.support:multidex:1.0.3'
    implementation 'de.hdodenhof:circleimageview:3.0.0'
    implementation 'com.google.android.gms:play-services-location:16.0.0'
    implementation 'com.github.bumptech.glide:glide:4.9.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:support-media-compat:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:support-compat:28.0.0'
}

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

styles.xml如下:

<resources>

    <!-- Base application theme. -->

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

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="colorAccent">@color/white</item>
    </style>

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

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

</resources>

项目中styles.xml的图像如下: styles.xml

重建项目结果图: Image of results on rebuilding project

7 个答案:

答案 0 :(得分:0)

请尝试在此处添加此依赖项:

 implementation "com.android.support:support-core-utils:28.0.0"

答案 1 :(得分:0)

删除这两个依赖项,

implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:support-compat:28.0.0'

答案 2 :(得分:0)

降级到27并检查或检查sdk 28是否已安装

答案 3 :(得分:0)

迁移到 Android-X 解决了该问题。

转到:

重构-> 迁移到AndroidX

答案 4 :(得分:0)

1. Close the Android Studio 
2. Delete the .AndroidStudio3.3 folder from File System
3. start Android Studio after that .AndroidStudio3.3 Folder Recreated Automaticall then 
   Your Error will be solved

答案 5 :(得分:0)

发布相关的 CircleImageView 版本和您的项目。

在您的项目中,您的支持库版本28.0.0 (pre-androidx和运行 androidx 版本的 CircleImageView version 3

,因此您必须升级项目androidx 将circleImageView版本降级2.x

答案 6 :(得分:0)

文件>使缓存无效/重新启动

为我工作。

相关问题