Join David Gassner for an in-depth discussion in this video Using the exercise files, part of Building Mobile Apps with Google Maps Android API v2.
This course is accompanied by exercise files that you can use to work through all of the applications that I build. I've copied my exercise files to my desktop. But you can place them anywhere on your hard disk. The exercise files are organized by chapter. Within each chapter, you'll find a set of zip files. And each zip file is an Eclipse project archive, intended to be imported before you start working through that exercise. At the beginning of the course, I'll describe how to get the ADT bundle.
That's Android developer tools, and how to fire up the version of Eclipse that's included in it. And before you integrate any maps, you'll need to download and install the Google Play Services library. After installation, it looks like this, and I'll show you where to get it and how to import it. After you get those basics set up for each movie, import the project for that movie. To import a project select file, import, then under general choose existing project into work space.
Click next and on this screen choose select archive file and browse and select the zip file for that exercise. After you complete the import process, you'll see that the project is imported. But for most developers, you'll see a bunch of errors. This is because when you import the project, it won't link to the Google Play services library correctly. Here is how you re-link, go to the new project that you just imported, right click and choose Properties, then go to the Android category.
You will see a link to the Google play services library, but you'll probably see this X, indicating that it is an invalid link, remove it click Add. Choose your copy of Google Play services library. Re link, and it should all work now. Don't worry about the specific path of your copy of the library. As long as you get the little checkmark icon, you're in good shape. Click OK. And after the project is rebuild those arrows should go away, here is the next issue might run into.
These projects were build on a computer that had Java 1.7 and this copy of eclipse was sent to a particular Java compliance level. If you see a whole bunch of Java arrows at this point, that means you need to change your Java compliance level. Go to the project and right click, choose properties and go to Java Compiler and set your compiler compliance level to 1.6. Even if you're using the Java 7 Developer's Kit, the Android Compiler requires this setting.
After making that change and clicking OK, you're Java errors will go away. And finally, here's the last thing you must do for each and every project. An Android app that uses Google maps requires something call an API key. The API key is a value generated by Google, and it's derived from a value that's unique to each and every development computer. Specifically to the debug key store for that computer. In my pre built projects, the API key is for my development computer and not yours.
Early on in the course I'll described how to set up your API key and then for each and every project in the course you must follow these steps Open the android manifest file for that project. Look at the file in XML view, scroll down to the bottom of the file, and look for this metadata tag, with a name of API key. This is the API key for my computer, it won't work on yours. Once you have goten your own API key that works on your debug key store on your development computer, copy and paste that key into this file.
You should then be able to run the application on a device. So, for example, I'll run this version of the application by going into the main activity. And running it on my device. I'm running the application on a Nexus 4 phone. If you can see the Google map, then you know your API key is working. It should be fully interactive. You should be able to rotate, zoom, choose different map types. And otherwise do everything that the Google maps API let you do.
If you have any trouble running the application, especially if you see just a white screen instead of an actual map. Double check your application manifest make sure that you are using your API key and not mine. And also make sure that all the permissions that are needed for Google Maps on Android are in your manifest file and spelled correctly. I'll describe all these permissions and how to set them up, and what they mean, early on in the course. So, with all that information about how to use the exercise files in this course Let's get started building Android Apps with Google Maps.
Note: An Android device with Android 3.0 (Honeycomb) or higher, and that has Google Play Store installed, is required to use the course exercises. (Kindle Fire and Nook devices do not qualify.) Finished mapping apps can be deployed on Android 2.2 (Froyo) or later.
- Setting up the developer tools
- Adding required permissions
- Getting a Google Maps API key
- Importing and linking the Google Play services
- Setting a map's initial state
- Geocoding an address
- Getting the current location programmatically
- Adding map markers
- Handling marker events
- Drawing lines, polygons, and circles
- Adding maps to existing apps