6

ok, steps im following.

1-create new project from existing source

2-select Android\android-sdk\extras\android\compatibility\v4\samples\Support4Demos

3-finish

So, my beautiful eclipse creates the project but he erase the R.java class from gen so i get errors from every class of the package. I thing

Also, style.xml give me some error.

This is killing me because i can learn nothing from this for 3 days and i my friend google is not helping with this.

thx in advance!

pata
  • 959
  • 2
  • 18
  • 35

4 Answers4

10

I tried the same thing in Eclipse, and I saw on Most every file, there was a failed import:

import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;

So, what I did to fix it, was:

  1. Right click on your project ("Support4Demos") in the navigation menu on the left.
  2. Click 'Properties'.
  3. Click 'Java Build Path' on the left hand navigation pane.
  4. Click 'Add External Jars' button on the right.
  5. Navigate to: "\android-sdk\extras\android\compatibility\v4"
  6. Choose "android-support-v4.jar", then click 'Open', then click 'Ok'.
  7. Left Click on your Project ("Support4Demos").
  8. Click 'Project' at the top, then click 'Clean', then click 'Ok'.

The last two steps might not be needed. But when you do all this, it may fix it. You would also need to fix any error in the XML file.

EDIT:
Try this:

  1. Right click on your project and choose "properties"
  2. Choose 'Android'.
  3. Make sure it's set on Android 3.2 or higher.

Android 3.2 was when the Holo theme was introduced.

Jorgesys
  • 124,308
  • 23
  • 334
  • 268
Reed
  • 14,703
  • 8
  • 66
  • 110
  • atm im facing the issue with the style.xml. any idea how to fix that one? error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo'. styles.xml /PruebaFrag/res/values-v11 line 19 Android AAPT Problem error: Error retrieving parent for item: No resource found that matches the given name 'android:style/Theme.Holo.DialogWhenLarge'. styles.xml /PruebaFrag/res/values-v11 line 23 Android AAPT – pata Nov 18 '11 at 22:23
  • @GuillermoVarini Updated my answer. Let me know if that fixes or not. :) – Reed Nov 18 '11 at 22:32
  • :o ok, now its 3.2 and dont have errors. But this compatibility is to run it low api android right? (1.6+) how can i set this for android 2.3 then? – pata Nov 18 '11 at 22:36
  • You compile against 3.2, then you just install it on 2.3 or whichever version you want. If it is properly backward compatible, then it should cause no errors. – Reed Nov 18 '11 at 22:37
  • now this worked :D the problem is that tabs and pager example are not working and i want this just for that :P error 11-18 22:50:28.701: ERROR/AndroidRuntime(358): java.lang.NoClassDefFoundError: com.example.android.supportv4.app.LoaderCustomSupport$AppListFragment – pata Nov 18 '11 at 22:51
  • @GuillermoVarini I'm really not sure what to tell you on that. I'd recommend asking a new question about that error if you can't figure it out. When developing, errors are a good thing(sometimes). They teach you a lot more than everything just working does. Point being, I recommend doing some research on your own first to try to figure out that error, and ask about it if you can't figure it out. This link may help: http://developer.android.com/reference/java/lang/NoClassDefFoundError.html – Reed Nov 18 '11 at 23:31
  • I believe that the above answer is not the recommended way of using the compatibility library - you are supposed to copy the library file to the /lib subfolder of your project rather then directly referencing the copy in the sdk. – Tom Jan 24 '12 at 18:16
  • I have the same problem and selecting API level 14 in project properties fixes it. I really don't know why the Manifest shows minSDK=4 but it uses a feature of API level 14 (it's android:stopWithTask). – emeraldhieu Apr 01 '12 at 20:03
1

Since ADT 17.0.0 issue you should put android-support-vX.jar to /libs folder and if you want to apply Holo theme in your application you should make targetSDKversion in AndroidManifest.xmlequals 11 minimum

teoREtik
  • 7,886
  • 15
  • 46
  • 65
0

R.java is gone because of the error you have in style.xml. Fix the error in Style.xml and R will be able to regenerate and all shall be swell.

EDIT:

Then go to:

Project -> Clean

ahodder
  • 11,353
  • 14
  • 71
  • 114
  • You also may need to then left click on Support4Demos, then click "Project" at the top, then click 'Clean' for it to actually re-generate the R.java file. – Reed Nov 18 '11 at 22:11
  • True fact. Completely forgot to mention that. Thanks for the reminder. – ahodder Nov 18 '11 at 22:13
  • This are the errors, any idea how to fix??...... error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo'. styles.xml /PruebaFrag/res/values-v11 line 19 Android AAPT Problem error: Error retrieving parent for item: No resource found that matches the given name 'android:style/Theme.Holo.DialogWhenLarge'. styles.xml /PruebaFrag/res/values-v11 line 23 Android AAPT Problem – pata Nov 18 '11 at 22:18
0

I disabeled automatic update, deleted bin and gen folder, cleaned (will give error just ignore), fixed project setup, added compatability library and then it worked :)

Warpzit
  • 27,966
  • 19
  • 103
  • 155