Search code examples
androidandroid-studioandroid-gradle-pluginandroid-build

Android studio wont recognize appcompat or any other default items


Today I re-opened an app(after a few months) on which I previously worked on a few months ago .But unfortunately everything seems to stop working for that app's code. I have searched through the internet on various hacks how to solve appcompatactivity not resolved

r Theme.AppCompat.Light.DarkActionBar not recognized

But I seem to have combination of all weirdest errors altogether..

Here is what I got as a gift from 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.

First of all I would like to clarify I have tried these following hacks-

1.Clean- Rebuild

2.Invalidate Cache-restart

3.Deleting .idea folder

4.Deleting the build folder

5.Changing appcompat version

NOTHING WORKED

Here is my build.gradle files-

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'

}

and

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
}

Any help is very much appreciated(Its full proof that a few months ago I used this android project successfully on android studio)


Solution

  • Ok, After different trial and errors I found a FIX , It should be the easiest method to carry out when Nothing is working!!

    Start a new Android Studio Project with Default settings..

    Then copy and replace the common contents of build.gradle(app and project) of the newly created project to the Problematic project,And sync

    Which should solve all of these kind of errors(But be sure that you have already tried out the hacks mentioned in the question-which failed for me and Was forced to find this new Solution..)

    Hope this will help to any other Persons facing any of these issues in future.