Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Android Support v4 Library Demo Programs

I'm interested in running the Android Support library demo projects for the v4 library. Using the Android SDK manager I've installed the Eclipse plugins, and APIs from 2.2 to 4.0.1. There are several issues involved, and the sample project as provided is far from running on my configuration, as downloaded.

To reproduce this error:

  • Install SDK and Eclipse Juno

  • Import the sample v4 compatibility project using File --> New --> New Project and choose "from existing code", targeting, for example, the Support4Demos folder in <Android-sdk-path>/extras/android/support

enter image description here

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

enter image description here

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

How do I get rid of these errors? I'd also like to understand why they are appearing so I can fix them in the future.

Thanks!

like image 371
Robert Karl Avatar asked Jan 15 '23 12:01

Robert Karl


2 Answers

Clean solution is to:

  • Right-click your project.
  • Choose "Android Tools"
  • Choose "Add support library".
  • Install the appropriate support library (the newest)

I can't really answer you on the why this problem happens, but I'm guessing the Android team doesn't supply the Android support library, because it's changing all the time, so not to get stuck on some older version, they want us to supply it on our own.

If errors still persists or new errors come up, right-click the project again and choose "Android tool" -> "Fix project properties"

Update: In conjuction to my answer, the way to remove the rest of the errors is to import the project another way than you did.

  • Select File -> New -> Other
  • Click Next
  • Write Android Sample
  • Select Android sample Project and click Next

Now add the Android support librarys as described above. You will get errors still however. To fix these, do the following:

  • Right-click your project and select "Properties"
  • Select Android
  • Select an SDK version equal to 3.0 or above
  • Select Ok and clean the project from the project menu.
  • All done ;-)

Now you won't be able to run the sample project on devices lower than Android 3.0. The reason is because of some dependencies on some themes and settings, that wasn't added before Android 3.0 apparently.

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

like image 72
Darwind Avatar answered Jan 24 '23 08:01

Darwind


You have to add the v4 support library.

In order to do that , please follow these steps :

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

This should remove the errors.

like image 20
Leeeeeeelo Avatar answered Jan 24 '23 07:01

Leeeeeeelo