Error "package android.support.v7.app does not exist"
I am new to android development, and I have been using the command line tools to create an android project. I followed all the instructions given in the tutorial at android developers. However, they are focused more on IDE users.
When I tried extending my MainActivity class from ActionBarActivity instead of just Activity, it threw the following error.
error: package android.support.v7.app does not exist
It was complaining about this import statement.
import android.support.v7.app.ActionBarActivity;
I made sure to visit the SDK manager, and it says Android Support Library is installed. I am truly stumped on this one, and I would really appreciate any help you guys could give me.
This might help: http://developer.android.com/reference/android/support/v7/app/ActionBarActivity.html
First of all check if your project is using androidx or android support library. Check gradle.properties file:
android.useAndroidX=true
android.enableJetifier=true
If it contains the above lines, it is using androidx with an old code from some old tutorial.
In build.gradle (module:app)
Use
implementation 'androidx.appcompat:appcompat:1.0.0'
Instead of
compile 'com.android.support:appcompat-v7:28.0.0'
Also in MainActivity.java : Use
import androidx.appcompat.app.AppCompatActivity;
instead of :
import android.support.v7.app.AppCompatActivity;
If the issue reported from MainActivity.java then replace
import android.support.v7.app.AppCompatActivity;
with
import androidx.appcompat.app.AppCompatActivity;