javaandroidandroid-studiocompiler-errorschrome-app-developer-tool

Error on Android studio ( Method doesn't override method from its superclass )


package com.example.mahaapptask2;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;


public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
// Here we link the btn with the activty in xml file
        Button btnHello = findViewById(R.id.btnHello);
        btnHello.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v)
            {
            System.out.println("Hello :)");
            }
        });

    }
}

After running the phone simulator this error occurs ( Method doesn't override a method from its superclass )so what I have to change?


Solution

  • Try add this line in import section: import com.example.mahaapptask2.R;