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
Downloading the Support LibrariesStart the android SDK Manager. In the SDK Manager window, scroll to the end of the Packages list, find the Extras folder. Select the Android Support Library item. Click the Install packages button.
androidx.appcompat.app.AppCompatActivity. Base class for activities that wish to use some of the newer platform features on older Android devices. Some of these backported features include: Using the action bar, including action items, navigation modes and more with the setSupportActionBar(Toolbar) API.
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With