Before we explore any of the code and learn our first bit of Java, you might be surprised to learn that we can already run our project. It will just be a blank screen but as we will be running the game as often as possible to check our progress, let's see how to do that now. You have three options:
The first option is the easiest to set up because we did it as part of setting up Android Studio. If you have a powerful PC you will hardly see the difference between the emulator and a real device. However, screen touches are emulated by mouse clicks and proper testing of the player's experience is not possible.
The second option using a real device has a couple more steps but once set up, is as good as option one and the screen touches are for real.
The final option takes a few minutes (at least) to prepare and then you need to manually put the created package onto a real device and install it.
Probably the best way is to use the emulator to quickly test minor increments in your code and then fairly regularly use USB debugging mode on a real device to make sure things are still as expected. Only occasionally will you want to export an actual deployable package.
If you have an especially slow PC or a particularly aging Android device, you will be fine just running the projects in this book using just one option or the other. Note that a slow Android phone will probably be OK and cope, but a very slow PC will probably not handle the emulator running games and you will benefit from running the games on your phone/tablet – especially the later games.
For these reasons, I will now go through how to run the game using the emulator and USB debugging on a real device.
Follow these simple steps to run the game on the default Android emulator.
You're done. Here is what the running game looks like so far:
Clearly, we have more work to do but it is a good start. Let's see how to do the same on a real device and then we can go about building Sub' Hunter further.
The first thing to do is to visit your device manufacturer's website and obtain and install any drivers that are needed for your device and operating system.
The next few steps will set up the Android device for debugging. Note that different manufacturers structure the menu options slightly differently to others. But the following sequence is probably very close, if not exact for enabling debugging on most devices:
We are now ready to learn some Java and add real code to the Sub' Hunter project.
3.142.121.153