Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Coding Academy - Android Get started - package R

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
Wooster



Joined: Tue Jul 19, 2011 8:47 pm
Posts: 2

PostPosted: Tue Jul 19, 2011 9:04 pm    Post subject: Coding Academy - Android Get started - package R Reply with quote

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
View user's profile Send private message
AndyBaxman
LXF regular


Joined: Tue Oct 04, 2005 9:47 am
Posts: 523

PostPosted: Wed Jul 20, 2011 10:53 am    Post subject: Reply with quote

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
View user's profile Send private message
Wooster



Joined: Tue Jul 19, 2011 8:47 pm
Posts: 2

PostPosted: Wed Jul 20, 2011 7:48 pm    Post subject: Reply with quote

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
View user's profile Send private message
AndyBaxman
LXF regular


Joined: Tue Oct 04, 2005 9:47 am
Posts: 523

PostPosted: Thu Jul 21, 2011 8:54 am    Post subject: Reply with quote

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 user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast