Search code examples
androidandroid-gradle-pluginappcompatactivity

Cannot resolve symbol AppCompatActivity


Although this question has been asked before, none of the solutions are working for me.

The problem is that suddenly out of nowhere Android Studio started throwing the error that Cannot resolve symbol AppCompatActivity. On clicking Alt+Enter on my Windows, it shows me

Add library 'com.android.support:appcompat-v7:27.0.2' to classpath

as one of the options.

Even though I have the following dependency in my gradle which always worked till today

implementation 'com.android.support:appcompat-v7:27.1.1'

So far I have tried

  1. Cleaning project
  2. Invalidating caches and restarting
  3. Deleting libraries folder from .idea folder and restarting studio
  4. Closing and reopening the project
  5. Removing the dependency from gradle, syncing with gradle and adding dependency again

None of these solutions work and I am not able to understand what the issue is. This already ended up wasting lots of development time. Can someone please help. Thanks!

Edit: Adding dependencies

dependencies {
    implementation project(':ratemyapp')
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation 'com.mcxiaoke.volley:library:1.0.18'

    implementation 'com.android.support:multidex:1.0.3'
    implementation files('libs/gcm.jar')

    // Facebook SDK Core only (Analytics)
    implementation 'com.facebook.android:facebook-core:4.33.0'

    // Facebook Login only
    implementation 'com.facebook.android:facebook-login:4.33.0'
    implementation 'com.braintreepayments.api:braintree:2.14.2'
    implementation 'com.braintreepayments.api:drop-in:3.4.0'

    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:customtabs:27.1.1'
    implementation 'com.android.support:animated-vector-drawable:27.1.1'

    /**
     * Google
     */
    implementation 'com.google.android.gms:strict-version-matcher-plugin:1.1.0'
    implementation 'com.google.android.gms:play-services-auth:16.0.1'
    implementation 'com.google.android.gms:play-services-base:16.0.1'
    implementation 'com.google.android.gms:play-services-maps:16.0.0'
    implementation 'com.google.android.gms:play-services-identity:16.0.0'
    implementation 'com.google.android.gms:play-services-location:16.0.0'
    implementation 'com.google.android.gms:play-services-places:16.0.0'
    implementation 'com.google.android.gms:play-services-nearby:16.0.0'
    implementation 'com.google.android.gms:play-services-gcm:16.0.0'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:mediarouter-v7:27.1.1'
    implementation 'com.google.android:flexbox:0.3.2'

    //compile files('libs/splunk-mint-4.2.1.jar')
    implementation 'com.android.support:design:27.1.1'

    // CardView
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.pixplicity.multiviewpager:library:1.0'
    implementation 'com.github.aakira:expandable-layout:1.4.1@aar'
    implementation 'me.everything:overscroll-decor-android:1.0.4'
    implementation 'org.apache.httpcomponents:httpmime:4.5.2'
    implementation 'commons-net:commons-net:3.3'
    implementation 'com.android.support:percent:27.1.1'


    /*For Request Server*/
    implementation 'com.squareup.okhttp3:logging-interceptor:3.9.1'
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava:2.3.0'
    implementation 'com.artemzin.rxjava:proguard-rules:1.1.6.0'

    /**
     * Animation.
     */
    implementation 'com.nineoldandroids:library:2.4.0'
    implementation 'com.daimajia.easing:library:1.0.1@aar'
    implementation 'com.daimajia.androidanimations:library:1.1.3@aar'
    implementation 'net.soulwolf.widget:ratiolayout:1.0.0'
    implementation 'com.jakewharton:butterknife:8.5.1'
    kapt 'com.jakewharton:butterknife-compiler:8.5.1'

    /**
     * Event Bus.
     */
    implementation 'org.greenrobot:eventbus:3.0.0'
    implementation 'com.wefika:flowlayout:0.4.1'

    /**
     * Ring capcha
     */
    implementation 'com.thrivecom:ringcaptcha:1.0.11@aar'

    /**
     * Zendesk
     */
    implementation 'com.zopim.android:sdk:1.3.7.1'
    implementation 'com.zendesk:support:2.0.0'
    implementation('com.twitter.sdk.android:twitter:3.3.0@aar') {
        transitive = true
    }
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.3@aar') {
        transitive = true
    }
    implementation('io.fabric.sdk.android:fabric:1.3.12@aar') {
        transitive = true
    }
    implementation 'io.branch.sdk.android:library:2.5.9'

    implementation 'com.mixpanel.android:mixpanel-android:5.+'
    implementation 'com.yqritc:android-scalablevideoview:1.0.4'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.google.dagger:dagger:2.12'
    kapt 'com.google.dagger:dagger-compiler:2.11'
    implementation 'com.google.dagger:dagger-android-support:2.11'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    kapt 'com.google.dagger:dagger-android-processor:2.11'

    // ViewModel and LiveData
    implementation 'android.arch.lifecycle:extensions:1.1.1'
    kapt "android.arch.lifecycle:compiler:1.1.1"

    // Room
    implementation 'android.arch.persistence.room:runtime:1.1.1'
    kapt "android.arch.persistence.room:compiler:1.1.1"

    // Paging
    implementation 'android.arch.paging:runtime:1.0.1'
    implementation 'com.jakewharton.timber:timber:4.6.0'

    // Test helpers for LiveData
    testImplementation 'android.arch.core:core-testing:1.1.1'

    // Test helpers for Room
    testImplementation 'android.arch.persistence.room:testing:1.1.1'
    implementation 'org.apache.commons:commons-lang3:3.6'
    implementation 'com.github.bumptech.glide:glide:4.5.0'
    kapt 'com.github.bumptech.glide:compiler:4.4.0'
    implementation 'com.github.rubensousa:gravitysnaphelper:1.5'
    implementation 'me.everything:overscroll-decor-android:1.0.4'
    implementation 'com.github.bumptech.glide:recyclerview-integration:4.4.0'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.8'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'android.arch.persistence.room:runtime:1.1.1'
    implementation 'android.arch.persistence.room:rxjava2:1.1.1'
    implementation 'android.arch.lifecycle:reactivestreams:1.1.1'
    implementation 'com.github.zcweng:switch-button:0.0.3@aar'
    implementation 'com.shuhart.bubblepagerindicator:bubblepagerindicator:1.0.6'
    implementation 'com.iarcuschin:simpleratingbar:0.1.5'
    implementation 'co.omise:omise-android:2.6.4'
    implementation 'com.airbnb.android:lottie:2.5.4'
    implementation 'com.adjust.sdk:adjust-android:4.13.0'
    implementation 'com.android.installreferrer:installreferrer:1.0'
    implementation 'io.card:android-sdk:5.5.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'android.arch.persistence.room:testing:1.1.1'
    androidTestImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test:rules:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.2'
    androidTestImplementation 'org.mockito:mockito-core:2.7.19'
    androidTestImplementation 'org.mockito:mockito-android:2.7.19'
    implementation 'net.cachapa.expandablelayout:expandablelayout:2.9.2'
    implementation project(':menu')
    implementation project(':base')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    implementation 'com.google.firebase:firebase-perf:16.2.0'
    implementation 'com.google.firebase:firebase-core:16.0.4'
    implementation 'com.google.firebase:firebase-analytics:16.0.4'
    implementation 'com.google.firebase:firebase-appindexing:16.0.2'
    implementation 'com.google.firebase:firebase-messaging:17.3.4'

    implementation 'com.google.android.instantapps:instantapps:1.1.0'

    implementation 'com.romandanylyk:pageindicatorview:1.0.2'
    implementation 'com.airbnb.android:lottie:2.5.4'
    implementation 'me.grantland:autofittextview:0.2.+'

    //OTP
    implementation 'com.poovam:pin-edittext-field:1.1.2'

    implementation 'jp.wasabeef:glide-transformations:4.0.1'

}

Edit: Top level gradle file

// Top-level build file where you can add configuration options common to all sub-projects/modules.
ext {
    compileSdkVersion = 27
    minSdkVersion = 16
    targetSdkVersion = 27
    zendeskSdkVersion = "2.0.0"
    appCompatVersion = "27.0.2"
}

buildscript {
    ext.kotlin_version = '1.2.71'
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.2.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.firebase:firebase-plugins:1.1.5'
    }
}
allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter()
    }
}

Log when trying to build project

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':MyModule:kaptDebugKotlin'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:103)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:73)
    at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
    at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:256)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:249)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:238)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:663)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:597)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.gradle.api.GradleException: Compilation error. See log for more details
    at org.jetbrains.kotlin.gradle.tasks.TasksUtilsKt.throwGradleExceptionIfError(tasksUtils.kt:16)
    at org.jetbrains.kotlin.gradle.internal.KaptWithKotlincTask.compile(KaptWithKotlincTask.kt:79)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:46)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:788)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:755)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:124)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:113)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:95)
    ... 33 more

Solution

  • Thanks to everyone for the help however I had to uninstall and reinstall Android Studio and only then the errors went away.