cannot find Symbol class ActionBarActivity (Android Recycled View)

Maxime Bodivit picture Maxime Bodivit · Feb 13, 2018 · Viewed 7.1k times · Source

I have some problem when i build graddle.. i don't understand where is the probleme, i read many things about that, but i can't find the solution.. i have already: download the Repository, put in the dependencies and the latest SDK version.

I try to make CardView in the HomeActivity.xml. I have also MyViewHolder.java, PageAdapter.java and `MyObject.java so.. i need some help If you want the other file, i have made 3 TabLayout . the code is in the 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 in 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 Manifeste.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>

Answer

GFPF picture GFPF · Mar 19, 2018

According to the documentation 'ActionBarActivity' has been deprecated and removed from support library, extend your Activity from 'AppCompatActivity' instead:

import android.support.v7.app.AppCompatActivity;

public class YourActivity extends AppCompatActivity

app/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'
}