| View previous topic :: View next topic |
| Author |
Message |
Wooster
Joined: Tue Jul 19, 2011 8:47 pm Posts: 2
|
Posted: Tue Jul 19, 2011 9:04 pm Post subject: Coding Academy - Android Get started - package R |
|
|
Hi,
I am having a problem compiling the "countdown" project. I created the project using "android", I copied the CountdownActivity.java and main.xml from the DVD and put them in the appropriate directories. When I run "ant debug" the project fails to compile stating "package R does not exist".
What do I have to do to overcome this problem?
Thanks. |
|
| Back to top |
|
 |
AndyBaxman LXF regular

Joined: Tue Oct 04, 2005 9:47 am Posts: 520
|
Posted: Wed Jul 20, 2011 10:53 am Post subject: |
|
|
I tend to use Eclipse for my Android dev work, so I can't tell you specifically how to fix your problem, but I can tell you what the problem is.
The "R" package is the compiled resource file generated from the resource XML files. In Eclipse the build scripts build it automatically when you run (and, therefore, build) the app.
You should have a "res" folder with sub folders like "drawable" and "values". These contain the XML resource definitions. For example you should see "strings.xml" in the values folder.
if strings.xml contains a definition for a string resource "foobar", then you can access in in your code using R.string.foobar once the resource has been compiled.
I imagine that you are not building the resource file. The tool you need to do this manually is called aapt (Android Asset Packaging Tool) and is in the SDK. _________________ Bomb #20: "Let there be light" |
|
| Back to top |
|
 |
Wooster
Joined: Tue Jul 19, 2011 8:47 pm Posts: 2
|
Posted: Wed Jul 20, 2011 7:48 pm Post subject: |
|
|
Many thanks for taking the time to reply.
I have now solved the problem although I still don't know what caused it.
Solution:
What I did was to remove the project, then re-create it, then copy the CountdownActiviy.java and main.xml to the appropriate folders and then I ran "ant debug".
When I first created the project I ran "ant debug" before changing the code. After I had modified the code I kept getting the failure.
Do you have to run "ant" in a different way if you have already built the binary once? |
|
| Back to top |
|
 |
AndyBaxman LXF regular

Joined: Tue Oct 04, 2005 9:47 am Posts: 520
|
Posted: Thu Jul 21, 2011 8:54 am Post subject: |
|
|
As I said, I'm afraid I don't use ANT, directly for Android development. I use Eclipse with the ADT plugin
It makes development, particularly resource editing, less of a grind.
If you do want to use Eclipse, you will need the "Eclipse for Java development" version. The Google info suggests the "classic" version will work, but it doesn't (missing dependencies). _________________ Bomb #20: "Let there be light" |
|
| Back to top |
|
 |
| View previous topic :: View next topic |
|