AppcompatActivity Error with Android studio

error: package android.support.v7.app does not exist
cannot resolve symbol appcompatactivity 2019
how to solve import android support v7 app appcompatactivity
appcompatactivity is not importing
error cannot find symbol public class splashactivity extends appcompatactivity
appcompatv7 error android studio
cannot resolve symbol annotation android studio
error: cannot find symbol class activitycompat

I'm getting this error when building android application with Android studio :

24192-24192/com.mkapp.apps.demo1 W/dalvikvm﹕ VFY: unable to find class referenced in signature (Landroid/os/PersistableBundle;)
08-20 10:53:23.605  24192-24192/com.mkapp.apps.demo1 I/dalvikvm﹕ Could not find method android.support.v7.app.AppCompatActivity.onCreate, referenced from method com.mkapp.apps.demo1.TourActivity.onCreate
08-20 10:53:23.605  24192-24192/com.mkapp.apps.demo1 W/dalvikvm﹕ VFY: unable to resolve virtual method 8393: Landroid/support/v7/app/AppCompatActivity;.onCreate (Landroid/os/Bundle;Landroid/os/PersistableBundle;)V
08-20 10:53:23.605  24192-24192/com.mkapp.apps.demo1 D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000

my dependencies :

    compile 'com.android.support:support-v4:22.2.1'
    compile 'com.google.android.gms:play-services:7.3.0'
    compile 'com.android.support:appcompat-v7:22.1.0+'
    compile 'com.android.support:multidex:1.0.1'

many thanks for your help

old activities which inherit from AppcompatActivity work fine. but if I create new one ,it get the error . here is my gradle.build :

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0"

    defaultConfig {
        applicationId "com.mkapp.apps.demo1"
        minSdkVersion 10
        targetSdkVersion 22
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
        multiDexEnabled true
    }
    dexOptions {
        incremental true
        javaMaxHeapSize "4g"
    }
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile project(':photocollage')
    compile project(':gWFacebookSDK')
//    compile project(':listViewAnimation')
    compile 'com.google.android.gms:play-services:7.3.0'
    compile 'com.android.support:appcompat-v7:22.1.0'

    compile 'com.android.support:multidex:1.0.1'
    compile files('libs/aws-android-sdk-2.1.0-core.jar')
    compile files('libs/aws-android-sdk-2.1.0-sns.jar')
    compile files('libs/dexmaker-1.1.jar')
    compile files('libs/dexmaker-mockito-1.1-custom.jar')
//    compile files('libs/listviewanimations_lib-core_3.1.0.jar')
    compile files('libs/signpost-commonshttp4-1.2.1.1.jar')
    compile files('libs/signpost-core-1.2.1.1.jar')
    compile files('libs/signpost-jetty6-1.2.1.1.jar')
    compile files('libs/twitter4j-core-4.0.1.jar')
    compile files('libs/universal-image-loader-1.9.3.jar')
}

You have this issue because you are trying to use onCreate (Bundle savedInstanceState, PersistableBundle persistentState), but this method is available only from API level 21.

I am able to reproduce the issue with this sample code on Android 4.4:

public class TourActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState, new PersistableBundle());
    }

    @Override
    public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
        super.onCreate(savedInstanceState, persistentState);
    }
}

And the issue is resolved removing every occurrence of PersistableBundle:

public class TourActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }
}

Check where you use PersistableBundle in your TourActivity and remove it or update your answer with the code of your activity.

can't resolve AppCompatActivity, Okay, to anybody who might stumble upon this now, Android Studio is very, But the real problem begins when all the above options doesn't  android.support.v7.app.AppCompatActivity Base class for activities that use the support library action bar features. You can add an ActionBar to your activity when running on API level 7 or higher by extending this class for your activity and setting the activity theme to Theme.AppCompat or a similar theme.

Update your support library to 23 and your compileSdkVersion to 23 in build.gradle.

compileSdkVersion 23

...

compile 'com.android.support:support-v4:23.0.0'
compile 'com.android.support:appcompat-v7:23.0.0'

Then sync your project with gradle files.

Also, Google Play Services is now 7.8.0

How to fix cannot resolve symbol AppCompatActivity, SOLVED: Cannot resolve symbol AppCompatActivity on Android Studio. If you have an old Duration: 4:32 Posted: Jun 20, 2018 NOTE: Make sure you are using same version for “appcompact” as that of “compileSdkVersion” . e.g. here we had compileSdkVersion as 27, hence appcompact version is 27.0.2

The problem is that your TourActivity is using a class available only from API level 21 PersistableBundle. The question here is why is doing that.

Remember you new activity have to inherit from AppCompatActivity as well.

Quick question, are you overriding public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) in the problematic activity? If you are doing it you probably are saving a reference to PersistableBundle which is not available in the device/emulator. Try removing it if you are not doing nothing there or comment it to try...

Error cant resolve AppCompatActivity in Android Studio fixed , in applicationID put your own app id otherxise wil not work apply plugin: 'com.​android Duration: 4:09 Posted: Jan 2, 2018 This is a known issue with Android Studio 1.3 preview build. It is reporting false positives with the Lint inspection. I extended AppCompatActivity and onCreate

First, update your libraries to the latest versions. Next, clean and rebuild your project.

Also, if this is a full list of libraries that you include:

    compile 'com.android.support:support-v4:22.2.1'
    compile 'com.google.android.gms:play-services:7.3.0'
    compile 'com.android.support:appcompat-v7:22.1.0+'
    compile 'com.android.support:multidex:1.0.1'

then you actually don't need to include this one

    compile 'com.android.support:multidex:1.0.1'

How to fix cannot resolve symbol 'AppCompatActivity' in android studio, +'-error (26-27-29,13) - Duration: 4:06. medka technology 58,920 views · 4:06. How To Duration: 2:51 Posted: Feb 25, 2019 For me, Even after upgrading to appcompat-v7:22.1.0, in which AppCompatActivty is added, the problem was not resolved for me, Android Studio was giving same problem. Cannot resolve symbol 'AppCompatActivity' Sometimes clearing the android studio caches help. In android studio I just cleared the caches and restarted with the following option--

Simply , Goto the File-> Invalidate Caches and Restart. Thanks

AppCompatActivity, Documentation. Developer guides · Design guides · API reference · Samples · Android Studio · Google Developers. Android  Teams. Q&A for Work. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information.

Can't resolve AppCompatActivity · Issue #27 · udacity/ud839_Miwok , I've imported this code into my android studio but having problem in it it says AppCompatActivity can't be resolved moreover style parent  Base class for activities that use the support library action bar features. You can add an androidx.appcompat.app.ActionBar to your activity when running on API level 7 or higher by extending this class for your activity and setting the activity theme to androidx.appcompat.R.style#Theme_AppCompat or a similar theme.

import android.support.v7.app.AppCompatActivity; <-- Cannot , Sometimes clearing the android studio caches help. In android studio I File->​Invalidate Caches/Restart <-- RL: This fixed the problem for me. R is a class generated automatically when your app builds. If there are build problems, then R does not get created. Your app clearly has build problems because it can't find class AppCompatActivity, which is part of the support library.

Cannot resolve symbol AppCompatActivity, the problem was not resolved for me, Android Studio was giving same problem. Cannot resolve symbol 'AppCompatActivity'. Sometimes  If you are using Android Studio as an IDE for android application development, you will encounter this problem with android SDK version 22 and above. This is because the ActionBarActivity class has been deprecated and Android Studio has yet to change the default Parent Activity class from ActionBarActivity to AppCompatActivity.

Comments
  • Update your support repository use the latest version 23
  • at last! if you're new to Android Studio and you've just downloaded the latest version (as of june 17 2016) by default your gradle will be set to use support libraries version 24, that seems to be very buggy at this point in time so even a simple activity built from untouched template will not work until you've changed this. VERY frustrating, but you got to this answer eventually so you're on the right way, don't give up :)
  • That's not helping i have latest dependencies still it get that error with device below api 21 results no layout is visible.
  • beacuse appcompat 23 is newest so if these don't be same, disagreement will appear