Error “package android.support.v7.app does not exi

2019-02-12 07:02发布

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

4条回答
地球回转人心会变
2楼-- · 2019-02-12 07:08

Your project is missing the support library from the SDK.

If you have no installed them, just right click on the project > Android Tools > Install support library.

Then, just import into workspace, as an Android project, android-support-v7-appcompat, located into ${android-sdk-path}/extras/android/support/v7

And finally, right click in the Android project > Properties > Android Tab. Push the Add button and add the support project "android-support-v7-appcompat" as dependency.

Clean your project and the must compile and work properly.

查看更多
Root(大扎)
3楼-- · 2019-02-12 07:10

For what it's worth:

I ran in to this issue when using Xamarin, even though I did have the Support packages installed, both the v4 and the v7 ones.

It was resolved for me by doing Build -> Clean All.

查看更多
Animai°情兽
4楼-- · 2019-02-12 07:33

Using Android Studio you have to add the dependency of the support library that was not indicated in the tutorial

dependencies {

    compile 'com.android.support:appcompat-v7:22.0.0'
}
查看更多
霸刀☆藐视天下
5楼-- · 2019-02-12 07:33

try to copy C:\Program Files\Java\jdk1.8.0_121 && C:\Program Files\Java\jre1.8.0_121 from other working PC then all (clean && rebuild)

查看更多
登录 后发表回答