Patrick.SE
Patrick.SE

Reputation: 4564

Snapshot's, the emulator and development

I just started Android development as part of a school assignment. I'm not sure how people efficiently re-compile their code to test them over the emulator? I've followed the first tutorial on the website with the snapshot feature enabled to get instant boot times, but then for some reason after I added a new activity I was getting Exceptions and errors.

The errors were so bad that the button ignored the onClick event. So I decided to wipe the data and run without the snapshot and the application was running fine.

I don't want to wait 40-50 seconds per boot-time every time I change something in the code. I've heard some people say you can even let the emulator on and it will automatically pick up the changes. Is this true even when you add activities to your configuration?

Also, how to you correctly close the emulator? Is it safe to just X out and re-run the app after a change?

One last thing, the tutorial doesn't talk about what the R variable is such as :

setContentView(R.layout.activity_main);

So what exactly is this R?

Upvotes: 0

Views: 62

Answers (2)

Teovald
Teovald

Reputation: 4389

R is an automatically generated class. It allows the compiler to make the link between your xml resources and your code.

R.layout.activity_main is activity_main.xml in your res/layout folder.

If you have an android phone/tablet, you can use it to test your code. it takes less than 3 seconds to update and install an app on my terminal. Or you can just let your emulator run during your whole coding session and just select it as the deployment target.

Upvotes: 1

Vincent Mimoun-Prat
Vincent Mimoun-Prat

Reputation: 28561

For the R part, this has been answered in other SO questions. For instance: Understand the R class in Android. You can also look at the developer docs: Accessing Resources

About the emulator, you can let it run while you develop. Then in Eclipse once you are happy with your changes, just debug the application and it should get uploaded to the emulator.

Upvotes: 1

Related Questions