Android studio 无法识别 appcompat 或任何其他默认项

Android studio wont recognize appcompat or any other default items

今天我重新打开了我几个月前开发的一个应用程序(几个月后)。但不幸的是,该应用程序的代码似乎一切都停止了。 我通过互联网搜索了各种黑客如何解决 appcompatactivity not resolved

r Theme.AppCompat.Light.DarkActionBar not recognized

但我似乎将所有最奇怪的错误组合在一起..

这是我从 Android Studio-

那里得到的礼物
java compiler errors(14 errors)
resource style/Animation.AppCompat.Dialog (aka com.actech.android.frienchat:style/Animation.AppCompat.Dialog) not found.    
resource style/Theme.AppCompat.Light.DarkActionBar (aka com.actech.android.frienchat:style/Theme.AppCompat.Light.DarkActionBar) not found.  
resource style/TextAppearance.AppCompat (aka com.actech.android.frienchat:style/TextAppearance.AppCompat) not found.    
resource style/Base.V7.Theme.AppCompat.Dialog (aka com.actech.android.frienchat:style/Base.V7.Theme.AppCompat.Dialog) not found.    
resource style/Base.V7.Theme.AppCompat.Light.Dialog (aka com.actech.android.frienchat:style/Base.V7.Theme.AppCompat.Light.Dialog) not found.    
resource style/Base.V7.ThemeOverlay.AppCompat.Dialog (aka com.actech.android.frienchat:style/Base.V7.ThemeOverlay.AppCompat.Dialog) not found.  
resource style/Base.V7.Theme.AppCompat (aka com.actech.android.frienchat:style/Base.V7.Theme.AppCompat) not found.  
resource style/Animation.AppCompat.Dialog (aka com.actech.android.frienchat:style/Animation.AppCompat.Dialog) not found.    
resource style/Theme.AppCompat.Light.DarkActionBar (aka com.actech.android.frienchat:style/Theme.AppCompat.Light.DarkActionBar) not found.  
resource style/TextAppearance.AppCompat (aka com.actech.android.frienchat:style/TextAppearance.AppCompat) not found.    
resource style/Base.V7.Theme.AppCompat.Dialog (aka com.actech.android.frienchat:style/Base.V7.Theme.AppCompat.Dialog) not found.    
resource style/Base.V7.Theme.AppCompat.Light.Dialog (aka com.actech.android.frienchat:style/Base.V7.Theme.AppCompat.Light.Dialog) not found.    
resource style/Base.V7.ThemeOverlay.AppCompat.Dialog (aka com.actech.android.frienchat:style/Base.V7.ThemeOverlay.AppCompat.Dialog) not found.  
resource style/Base.V7.Theme.AppCompat (aka com.actech.android.frienchat:style/Base.V7.Theme.AppCompat) not found.

首先,我想澄清一下,我已经尝试过以下技巧-

1.Clean- Rebuild

2.Invalidate Cache-restart

3.Deleting .idea folder

4.Deleting the build folder

5.Changing appcompat version

没有效果

这是我的 build.gradle 个文件-

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

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.actech.android.frienchat"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    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:recyclerview-v7:27.1.1'
    implementation 'com.android.support:support-annotations:28.0.0'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.google.firebase:firebase-core:16.0.5'
    implementation 'com.google.firebase:firebase-database:16.0.4'
    implementation 'com.google.firebase:firebase-messaging:17.3.4'
    implementation 'com.google.firebase:firebase-storage:16.0.4'
    implementation 'com.google.firebase:firebase-auth:16.0.5'
    implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
    implementation 'com.google.android.gms:play-services-auth:16.0.1'
    implementation 'com.google.firebase:firebase-config:16.1.0'
    implementation 'com.github.bumptech.glide:glide:4.8.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
    implementation 'com.github.chrisbanes:PhotoView:2.1.3'
    implementation 'com.android.support:cardview-v7:27.1.1'

}

build.gradle(Project)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.0.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url "https://jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

非常感谢任何帮助(这充分证明了几个月前我在 android 工作室成功使用了这个 android 项目)

好的,经过多次尝试和错误我找到了一个 FIX,这应该是在没有任何工作时执行的最简单的方法!!

使用默认设置启动一个新的 Android Studio 项目..

然后将新建项目的build.gradle(app and project)的公共内容复制替换到Problematic项目中,并sync

这应该可以解决所有这些类型的错误(但是请确保您已经尝试过问题中提到的黑客攻击——这对我来说失败了,被迫找到这个新的解决方案.. )

希望这对将来面临这些问题的任何其他人有所帮助。