Want to use ViewPager, cannot get android.support.

2019-02-22 14:33发布

问题:

EDIT Sorry about all the pictures. I tried to give you the best idea of where I am at.

I am trying to get ViewPager working on my application, but it will not recognize the Support Library that I downloaded in the SDK manager.

I am coding for SDK Version 10. This is a screen shot of my SDK Manager:

After installing the Android Support Library and the most recent Tools, I went to Help >> Check for Updates. After running this I receive the two pop ups shown below.

The Problem Occured pop up says that it can't find a repository at that site. I installed the Sequoyah Natice Code Support when I first started developing this application but have never used it. I tried to re-install the package to get rid of this pop-up but it will not let me as it is already installed.

In my code I get an error when trying to import android.support.v4.view.ViewPager;. The screen shot is below. When I hover my cursor over the import line, it says The import android.support.v4 cannot be resolved.

回答1:

To add the Android Support Library to an existing Android Project:

  • Right click on your project
  • Click Android Tools
  • Click Add Support Library

That should take care of setting up the android-support jar so it can be used by the project.



回答2:

For Android Studio 1.2.2

  • Right click on your project from the file hierarchy (should say "app")
  • Select "Open Module Settings" from the menu
  • Click on the "Dependencies" tab
  • Click the plus button at the bottom
  • Select "Library dependency"
  • Search/Choose your desired support library
  • Click OK