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

时间:2019-05-01 14:06:57

标签: android android-studio android-gradle android-build

今天,我几个月前重新打开了一个应用程序(几个月后),但是不幸的是,一切似乎都停止了该应用程序的代码。 我已经在互联网上搜索了各种技巧,以解决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。使缓存重新启动无效

     

3。删除.idea文件夹

     

4。删除构建文件夹

     

5。更改appcompat版本

什么都没做

这是我的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 studio上成功使用了这个android项目)

1 个答案:

答案 0 :(得分:0)

好吧,经过不同的尝试和错误,我发现了一个FIX,这应该是在什么都不起作用的情况下执行的最简单的方法!

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

然后将新创建的项目的build.gradle(应用程序和项目)的通用内容复制并替换为问题项目,并进行同步

应该解决所有这些类型的错误(,但是请确保您已经尝试了问题中提到的hack,但这些错误对我来说是失败的,因此被迫找到了这个新解决方案。

希望这对将来遇到这些问题的其他人有帮助。