Java – Symbol class not found ActionBarActivity (Android Recycle View)

Symbol class not found ActionBarActivity (Android Recycle View)… here is a solution to the problem.

Symbol class not found ActionBarActivity (Android Recycle View)

I’m having some issues building gradle: I don’t understand what the problem is, I read a lot about that but I can’t find a solution:
I’ve already: downloaded the Repository, put in dependencies and the latest SDK version.

I tried creating a CardView in HomeActivity.xml. I also have MyViewHolder.java, PageAdapter.java and ‘MyObject.java so: I need some help
If you want other files, I’ve made 3 TabLayout. The code is in MainActivity.java.

Information:Gradle tasks [clean, :app:assembleDebug]
C:\...........\HomeActivity.java
Error:(16, 35) error: cannot find symbol class ActionBarActivity
Error:(26, 5) error: method does not override or implement a method from a supertype
Error:(28, 9) error: cannot find symbol variable super
Error:(29, 9) error: cannot find symbol method setContentView(int)
C:\Users\cozakk\AndroidStudioProjects\MaximeBodivitVisionApp\app\src\main\java\com\maximebodivit\maximebodivitvisionapp\PagerAdapter.java
Error:(21, 24) error: incompatible types: HomeActivity cannot be converted to Fragment
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Information:BUILD FAILED in 26s
Information:6 errors
Information:0 warnings
Information:See complete output in console

In this file, I have ActionBarActivity, onCreate, setContentView red….

HomeActivity.java

package com.maximebodivit.maximebodivitvisionapp;

import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by cozakk on 13/02/2018.
 */

public class HomeActivity extends ActionBarActivity {

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_home, container, false);
    }

private RecyclerView recyclerView;

private List<MyObject> cities = new ArrayList<>();

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_home);

Fill city
        ajouterVilles();

recyclerView = (RecyclerView) recyclerView.findViewById(R.id.recyclerView);

recyclerView.setAdapter(new MyAdapter(cities));
    }

private void ajouterVilles() {
        cities.add(new MyObject("France","http://www.telegraph.co.uk/travel/destination/article130148.ece/ALTERNATES/w620/parisguidetower.jpg"));
        cities.add(new MyObject("Angleterre","http://www.traditours.com/images/Photos%20Angleterre/ForumLondonBridge.jpg"));
        cities.add(new MyObject("Allemagne","http://tanned-allemagne.com/wp-content/uploads/2012/10/pano_rathaus_1280.jpg"));
        cities.add(new MyObject("Espagne","http://www.sejour-linguistique-lec.fr/wp-content/uploads/espagne-02.jpg"));
        cities.add(new MyObject("Italie","http://retouralinnocence.com/wp-content/uploads/2013/05/Hotel-en-Italie-pour-les-Vacances2.jpg"));
        cities.add(new MyObject("Russie","http://www.choisir-ma-destination.com/uploads/_large_russie-moscou2.jpg"));
    }
}

Android list .xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.maximebodivit.maximebodivitvisionapp">

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=". MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=". SplashScreenActivity"></activity>
    </application>

</manifest>

Solution

According to documentation ActionBarActivity has been deprecated and removed from the support library in favor of extending your activity: from AppCompatActivity

import android.support.v7.app.AppCompatActivity;

public class YourActivity extends AppCompatActivity

Application/build.gradle

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId 'your_app_id'
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"

}
    }

dependencies {
    implementation 'com.android.support:appcompat-v7:27.1.0'
}

Related Problems and Solutions