【问题标题】:How to fix "Cannot resolve symbol 'app' " in android studio?如何在android studio中修复“无法解析符号'app'”?
【发布时间】:2019-09-07 13:19:17
【问题描述】:

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的图片如下:

重建项目的结果图片:

【问题讨论】:

  • 将错误代码添加为文本而不是图像
  • @Basi 感谢回复我添加了图像,因为在代码中无法显示 android studio 在重建项目时显示的错误。
  • @GovindParasha 我已经阅读了该答案,但不幸的是对我不起作用
  • @RanaHamzaKhursheed 检查this 以获取构建错误日志

标签: java android android-appcompat


【解决方案1】:

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

为我工作。

【讨论】:

    【解决方案2】:

    问题相关的CircleImageView版本和你的项目。

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

    所以你必须升级你的项目androidx降级circleImageView版本2.x

    【讨论】:

      【解决方案3】:
      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
      

      【讨论】:

      • 感谢您的贡献,问题已解决。我升级到了 AndroidX。
      • 哟兄弟!坚持下去。
      【解决方案4】:

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

      转到:

      重构 --> 迁移到AndroidX

      【讨论】:

        【解决方案5】:

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

        【讨论】:

          【解决方案6】:

          去掉这两个依赖,

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

          【讨论】:

            【解决方案7】:

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

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

            【讨论】:

            • 你能把问题中的样式代码传过来吗?
            • stackoverflow.com/questions/17870881/… 也可以试试这个链接
            • 现在检查问题
            • 输入parent="android:Theme.Light"这个而不是你的代码
            • 替换为 parent="android:Theme.Light" 仅删除特定行上的错误,因为我认为错误是由于 appcompat 库引起的。
            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2018-05-03
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2017-08-29
            • 1970-01-01
            相关资源
            最近更新 更多