Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio cannot resolve ActionBarActivity

I have tried invalidating the caches and restarting but it still shows up and will not compile and run as it used to before. I tried renaming the class file if i remember correctly and must have changed the name on something that made this how up. It also gives me the same error where findViewById, .oncreate, and setContentView. I migh have also renamed or tried to rename one of the packages because it was examplecom and it wouldnt allow me to upload it.

package com.threedeestone.mike.threedeestone;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.widget.EditText;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import java.text.DecimalFormat;


public class MainActivity extends ActionBarActivity {
like image 269
Mike Stone Avatar asked Feb 10 '23 06:02

Mike Stone


1 Answers

To use the ActionBarActivity or the AppCompatActivity you have to add the appcompat library to your dependencies.

Add in your build.gradle file the last version:

dependencies {
    ...
    compile "com.android.support:appcompat-v7:23.0.0"
}

The version 23.0.0 requires to compile the project with API 23.
Otherwise you can use the 22.2.1.

Also pay attention.
The ActionBarActivity is deprecated. Check the official javadoc.
You should use the AppCompatActivity.

like image 190
Gabriele Mariotti Avatar answered Mar 06 '23 06:03

Gabriele Mariotti