Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
105 views
in Technique[技术] by (71.8m points)

java - Android appcompat v7 error

Being new to Android developent I followed the simplest of tutorials, built a new android project, accepting all default settings (built it for kitkat). To my dismay I have an un-planned project - appcompat_v7, along with the errors:

The container 'Android Dependencies' references non existing library 'C:Users...workspaceappcompat_v7inappcompat_v7.jar'

and twice the following

The project cannot be built until build path errors are resolved

Is there a quick way to fix these? Is this a sign of how difficult, and bugged with unpleasant surprises learning Android is going to be?

(Hope it will not be similar to learning IOS 6 years ago...)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The appcompat_v7 library is added by default to an Android project. You will most likely need it for any demo projects you start making.

To correctly add this library, follow these steps:

For Android Studio:

1. Ensure that you have the Android Support Repository installed in your SDK Manager:

enter image description here

2. In your build.gradle file, include the following implementation statement

implementation 'com.android.support:appcompat-v7:+'

within the dependency bracket.

3. Perform a Gradle sync with the Sync Project button.


~LEGACY ANSWER~:

For Eclipse:

The trick is, you need to clean & build the appcompat_v7 project. Go to

Project -> select Clean -> select the project. 

After doing this, if the project does not get built automatically, right click on the project in the package explorer and select Build Project. Now the .jar file will be generated in the project's bin folder. After that, clean & build all projects that reference appcompat_v7.

Now the library should be correctly referenced by all projects that need it.

Note also that:

  • You must have the latest versions of SDK Tools / Build Tools / Platform Tools. If you try this and it doesn't work, then go to the Android SDK Manager and make sure you have the latest versions of the required tools.
  • In case your project only requires API level 14 (Ice Cream Sandwich) & above, select API level 14 for "minimum required SDK" in the project wizard when you create a new project. Now the appcompat_v7 library will not be required for this project, and the application will use the native ActionBar class which is present in AOSP builds from ICS onwards.

Further References:

1. How to add Android Support v7 libraries in eclipse.

2. Android actionbar how to add supporting library v7 appcompat for Eclipse.

3. android-support-v7-appcompat library project won't work.

4. Difference between android-support-v7-appcompat and android-support-v4.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...