Launch Android v4 Demo Support Program

I'm interested in the Android Support Library demos for the v4 library. Using the Android SDK manager, I installed the Eclipse plugins and APIs from 2.2 to 4.0.1. There are several problems, and the sample project that was provided does not work in my configuration as it was loaded.

To reproduce this error:

  • Install SDK and Eclipse Juno

  • Import the v4 sample compatibility project using File β†’ New β†’ New Project and select β€œfrom existing code”, for example, targeting, the Support4Demos folder in <Android-sdk-path>/extras/android/support

enter image description here

  • Open the AccessibilityManagerSupportActivity.java file. The following errors will appear.

enter image description here

  • Open res/values-v11/styles.xml . The following errors occur. enter image description here

How can I get rid of these errors? I would also like to understand why they appear, so I can fix them in the future.

Thanks!

+4
source share
4 answers

Pure solution:

  • Right click on your project.
  • Select "Android Tools"
  • Select "Add Support Library."
  • Install the appropriate support library (latest)

I can not answer the question of why this problem occurs, but I assume that the Android team does not provide the Android support library, because it is constantly changing, so do not get hung up on some old version, they want us to supply it by yourself.

If errors still persist or new errors appear, right-click the project again and select "Android Tool" β†’ "Fix Project Properties"

Update: In response to my answer, the way to remove the remaining errors is to import the project in a different way than you.

  • Choose File β†’ New β†’ Other
  • Click "Next"
  • Write an Android Sample
  • Select a sample Android application and click Next.

Now add the Android support libraries as described above. However, you will get errors. To fix this, follow these steps:

  • Right-click the project and select "Properties"
  • Choose Android
  • Select an SDK version of 3.0 or greater.
  • Select "OK" and clear the project in the project menu.
  • Done; -)

Now you will not be able to run a sample project on devices below Android 3.0. The reason is due to some dependencies on some themes and settings that were not added before Android 3.0.

It doesn't make sense why Google did it, but they did it. You can try to remove the specific dependencies of SDK +11 (Android 3.0), but it will take some time - there are more errors than you actually see, especially in XML files.

+6
source

You need to add v4 support library.

To do this, follow these steps:

  • Choose your project.
  • Click Project on the menu.
  • Select Properties .
  • Click Java Build Path .
  • Click the Libraries tab.
  • Click Add External JARs .
  • Select the main Android SDK directory that you installed, then go to additional β†’ android β†’ support β†’ v4 , and then select android-support-v4.jar and click Open .
  • Click OK .

This should fix the errors.

+3
source

Please check that your libs folder contains android-support-v4.jar support or not. if you do not add this jar file to the libs folder. Copy the android-support-v4.jar file from any project and paste it into the libs folder of your project.

0
source

I spent the whole night on this, but cannot solve this problem. I finally decided by chance: I changed some file in the demo and saved it, and then changed it, it cleared all the errors. I think that when you change the file and save, eclipse builds the project and generates R.java.

0
source

Source: https://habr.com/ru/post/1435985/


All Articles