Android Application Development

Errata for Android Application Development

Submit your own errata for this product.


The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update



Version Location Description Submitted By Date Submitted Date Corrected
Printed
Page 20
"Sources (under src)" paragraph

The Package name being discussed is "com.oreilly.helloworld", but here typo as "com.android.helloworld"

Note from the Author or Editor:
Fortunately, Eclipse will catch and correct this automatically...

Puneetkr  Jun 10, 2009 
PDF
Page 21
2.1.1 (Creating an Android Developement Environment) - 2. (Install Eclipse) - Linux and Mac OS X

Eclipse/Android SDK buggy when user does not have write permissions to installed directory tree. A fix is to install both Eclipse and the Android SDK to the user's home directory. (I used "/home/myname/local/eclipse" and "/home/myname/local/android-sdk/").

Note from the Author or Editor:
This is true, but it is very well known behavior for Eclipse. With some versions of eclipse it is possible to have the main installation in a shared, read-only directory, with other, user-specific plug-ins in a writable directory

oblongata  May 25, 2009 
PDF
Page 23
Topic 6.d. Install the Android plug-in (ADT)

Stale URL for Eclipse Android Plug-in ADT "https://dl-ssl.google.com/android/eclipse" is no longer valid. It seems to have been replaced by "http://dl-ssl.google.com/android/eclipse/site.xml" Phooey on Google for another catastrophic undocumented change. Cheers to you guys at ORA for trying to keep up with the radical SDK changes.

Note from the Author or Editor:
I think either will work... although you might need a final '/' in the first version (https://dl-ssl.google.com/android/eclipse/). Eclipse should look for "site.xml" when given a URL that refers to a directory. Thanks for the contribution!

oblongata  May 25, 2009 
Printed
Page 35
Boxed example

I am stumbling from the gate, having trouble to load and start the main MJAndroid example. On page page 35, the books says I should execute: $ emulator $ adb install MJAndroid-1.0.0.apk It didn't work literally. Instead I had to do (in android SDK's tools directory): $./android create avd --target 2 --name my_avd $ ./emulator -avd my_avd Then I downloaded MJAndroid.apk (I could not find MJAndroid-1.0.0.apk file from the website), and copied it to the tools directory. Now I issued $./adb install MJAndroid.apk But I get the following error message: 2028 KB/s (69445 bytes in 0.033s) pkg: /data/local/tmp/MJAndroid.apk Failure [INSTALL_FAILED_MISSING_SHARED_LIBRARY] ??? I wish the book had a clearer instruction even for newbies, at least for the main example.

Note from the Author or Editor:
You are correct! As you, no doubt, noticed immediately, the instructions in the book are for version 1.1 of the SDK. Since the book was released, Google has updated the SDK to version 1.5. Most of what you need to do has not changed: you still need the SDK and Eclipse. The changes are mostly in how you setup the emulator. There are good instructions for how to do that here: http://developer.android.com/guide/developing/tools/avd.html You need to create an AVD (this is, essentially, the description of the specific hardware/software platform you want to emulate). You should choose type 3, the Google extensions. Once you get the AVD created, everything should go just as described in the book.

Sy  Jun 10, 2009 
Printed
Page 35
Boxout 'Running the MJAndroid code'

PS - I'm aware you responded to oblongata's report of this same issue with a pointer to Google's page about AVDs, but the problem still occurs using either a version 1 or version 3 AVD (your response didn't make it entirely clear which was more appropriate). I've spent days messing with different versions of AVD, different versions of the SDK, and trying to find the older version of the ADT. Can you please provide readers with an *exact* list of the most recent software - AVD device version, SDK version, ADT version, along with instructions to get the MJAndroid to run? We paid good money for your book. This is incredibly frustrating.

Note from the Author or Editor:
I have run all of our applications, using a type 3 AVD

Anonymous  Jul 18, 2009 
PDF
Page 36
3.3 (Downloading the MJAndroid Code)

The downloaded tarball at http://www.oreilly.com/catalog/9780596521479 contains the R.java file in the src/ tree, "src/com/microjobsinc/mjandroid/R.java", it should not. This file should be built by the ADT. The reason being is because the later SDK's will build R.java to the gen/ tree "gen/com/microjobsinc/mjandroid/R.java". When the ADT builds R.java to the gen tree, the build then fails if there is an existing R.java in the src tree. A quick fix is for the user to delete R.java from the src tree.

Note from the Author or Editor:
You are correct, as a generated file, it would be better if we'd cleaned R.java out of the directory tree, before we archived it. R.java will be rebuild, correctly, even though it is present in the tarball.

oblongata  May 25, 2009 
PDF
Page 43
3.5.2 Loading and Starting the Application

Note: Project builds and installs to emulator, but terminates on runtime error, “The application com.microjobsinc.mjandroid (process com.microjobsinc.mjandroid) has stopped unexpectedly. Please try again. [Force close]” CODE WARNINGS RECIEVED: src/com/microjobsinc.mjandroid/EditJob.java: import com.microjobsinc.mjandroid.MicroJobsDatabase.JobsCursor is never used src/com/microjobsinc.mjandroid/MicroJobs.java: onCreate(Bundle): local variable myLocation is never read. src/com/microjobsinc.mjandroid/MicroJobsList.java: import android.app.AlertDialog is never used import android.content.DialogInterface is never used import android.os.Handler is never used import android.os.Message is never used (my development environment: IDE=eclipse-jee-ganymede-SR2-linux-gtk-x86_64 SDK=android-sdk-linux_x86-1.5_r1 (2009-04-22) Platform=1.1, API-level=2 )

Note from the Author or Editor:
In all likelihood, you have not set up your emulator correctly. Android is changing quickly. As you certainly noticed, you've downloaded SDK v1.5, not v1.1, the one against which the book was written. Although, by *far* most of the book is still accurate, in this one area (configuring the tools), the new version of the SDK is not backward compatible. There are excellent instructions on how to set the new tools up, here: http://developer.android.com/guide/developing/tools/avd.html Hope that helps!

oblongata  May 25, 2009 
PDF
Page 43
3.5.2 Loading and Starting the Application: Running the MJAndroid Code

The text says to use the prebuilt apk (which is correctly signed) if we wish to run the application, and to read Chapter 7 if we wish to learn how to sign then run our own built code. However, the prebuilt .apk is misnamed. The text refers to it as MJAndroid-1.0.0.apk, the correct name is MJAndroid.apk. The text also neglects to give the exact URL from which to acquire it (and there are several same-named files in different "examples" tarballs). The tarball that worked for me was: "http://examples.oreilly.com/9780596521479/example_android_2009_02_08.tar.gz", and not the one in "http://examples.oreilly.com/9780596521479/MJAndroid.zip". There is another tarball in that same directory with a similar name "http://examples.oreilly.com/9780596521479/example_android.tar.gz". But this tarball does not have any MJAndroid.apk. If you were to consolidate the tarballs, removing any extraneous files, it would greatly assist the reader in following code examples.

Note from the Author or Editor:
You are correct. Glad you found the actual locations

oblongata  May 25, 2009 
Safari Books Online
43
3.5.2. Loading and Starting the Application

Section 3.5.2 (about how to get the sample MJAndroid app running) explains there is a problem with the Map api key. The example application will not run unless it is fixed. The text suggests a method to fix it with loading materials from the samples. (MJAndroid-1.0.0.apk) In the errata other readers have noted that there is the confusion of several examples with different names in the directory listed. Also most of the examples don't have the file indicated. One reader said he found it under another name. (MJAndroid.apk) The problem persists. I could not even find the file under the new name. I think I downloaded every example. Mistakes happen but it is hard to understand why these easy-to-fix problems would still be there after all the reader comment???? I suggest you get a clean version of the needed file with a name that matches the text out in the clear (not embedded in compressed files). thanks

Note from the Author or Editor:
The key file is not where the book claims it should be, but hidden in zip/tar files. It is there, but it sure is confusing

Anonymous  Aug 16, 2009 
Safari Books Online
43
Section 3.5.2

Hi there, I have read the previous errata submissions and followed the AVD web page instructions for 1.5. I have two AVDs, one for the first

Note from the Author or Editor:
We find in surprising that readers download a version of the Android SDK that is clearly a different version than the one discussed in the book, and don't turn to the, reasonably good, installation instructions provided by Google. You are correct. The Cupcake SDK requires the configuration of AVDs (v1.0 did not). We will address this in subsequent versions of the book.

Lee Crampton  Aug 19, 2009 
Printed
Page 47
2nd Paragraph, just under the first first code segment

There is a minor typo in the bundle name

Note from the Author or Editor:
How did we miss that?

Mike  Aug 09, 2009 
PDF
Page 52
4th Paragraph

Note from the Author or Editor:
Right you are.

oblongata  May 26, 2009 
PDF
Page 54
last paragraph (code listing)

The text declares longitude and latitude to be of type double. But the source code downloaded from examples declares them as type int. Also, your text is referring to the Bundle as savedInstanceState, whereas the actual source code still uses the old SDK name icicle. (A minor difference I know, as long as the naming's consistent. But this might confuse new programmers.)

Note from the Author or Editor:
You are correct on both counts. Thanks.

oblongata  May 27, 2009 
PDF
Page 67
3rd paragraph

Hard returns at parentheses surrounding adb: Android Debug Bridge ( adb ) Instead of just: Android Debug Bridge (adb)

Note from the Author or Editor:
I do not have access to the PDF version of the book. If those lines have hard returns in them, as you state, they are incorrect. The printed version contains no such errors.

oblongata  May 28, 2009 
Printed
Page 67
bottom

The solution to the substring problem is not quite true: you state that people assume the substring call to have the number of letters as a parameter. Even then, substring(0,6) would be wrong. The actual problem is that the second parameter does not denote the last character but the one BEHIND the last one. Greetings, Christian

Note from the Author or Editor:
Good call. Thanks.

Anonymous  Jul 19, 2009 
PDF
Page 71
Fig 5-3 (main.xml in Eclipse)

file contents in the figure is totally different than that of the file in "http://examples.oreilly.com/9780596521479/example_android_2009_02_08.tar.gz" The tarball example file is listed below (note: RelativeLayout instead of Linear, as well as no WebView section.) <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffc5d1d4" > <com.google.android.maps.MapView android:id="@+id/mapmain" android:layout_width="fill_parent" android:layout_height="fill_parent" android:clickable="true" android:apiKey="0EHPt9AwkePFgASSLmLJYWuD3aw7d_h1vWNE66A" /> <TextView android:id="@+id/lblMicroJobsToday" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="MicroJobs for You Today Near:" android:textSize="20dp" android:textColor="#FF000000" android:layout_centerHorizontal="true" android:gravity="top" /> <Spinner android:id="@+id/spnLocations" android:layout_width="250dp" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="2dp" android:layout_below="@+id/lblMicroJobsToday" /> <Button android:id="@+id/btnShowList" android:layout_width="150dp" android:layout_height="wrap_content" android:text="List Jobs" android:textSize="20sp" android:gravity="center_vertical" android:layout_centerInParent="true" android:layout_alignParentBottom="true" /> </RelativeLayout>

Note from the Author or Editor:
If you look at the website you will see that there are two version of the example, one directly from the book, and one extended for Cupcake. We intend to use the website to keep the book up-to-date with the (rapidly!) changing Android environment. I think we need a README file, at the top of the book site, describing what's where.

oblongata  May 30, 2009 
PDF
Page 83
heading of 3rd full paragraph

unnecessary hard returns around

Note from the Author or Editor:
I do not have access to the PDF version of the book. If those lines have hard returns in them, as you state, they are incorrect. The printed version contains no such errors.

oblongata  Jun 01, 2009 
PDF
Page 83-85
Throughout pp83+84, top of p85

unnecessary hard returns around

Note from the Author or Editor:
All of these corrections appear to be accurate

oblongata  Jun 07, 2009 
PDF
Page 84
First paragraph

The book describes several command line options to adb, in particular how to read the radio and events logs. The version of ADB I'm using (v1.0.20) does not accept the referenced options: adb -b radio adb -b events However, interfixing the statements with "logcat" renders the desired results: adb logcat -b radio adb logcat -b events

Note from the Author or Editor:
This is correct. As developers will notice immediately, the book was written against version 1.1 of the Android SDK. One of the very few substantive changes between 1.1 and 1.5 is a much improved toolkit, especially the introduction of AVDs. To get the latest, look here: http://developer.android.com/guide/developing/tools/avd.html

oblongata  Jun 07, 2009 
PDF
Page 88
Sect 5.2.6.1 Trace data collection (top of page)

Adding "-sdcard filename" to "Window->Preferences->Android->Launch" did not map the mksdcard created image to the emulator. I had to: Window->Android AVD Manager Then delete the AVD I had created at an earlier step, then recreate it but specify the sdcard size. Because Eclipse/IDE will not allow the addition of an SD card after creation, I had to delete, recreate. #################### Also note the the x.trace file created does NOT contain any data (file size is zero): -rw-r--r-- 1 username username 0 2009-06-11 00:08 x.trace Consequently, none of the Traceview techniques mentioned in this section render the desired displays. When entering "traceview x.trace", "Key section does not have an *end marker" error message results.

Note from the Author or Editor:
AVDs are a great addition to the SDK (they allow you to specify details of the exact hardware/software you want to emulate). Unfortunately they did not exist when the book was written: Anything that concerns AVDs and their management is new and not described in the book. Fortunately, there's pretty good information on how to manage AVDs here: http://developer.android.com/guide/developing/tools/avd.html

oblongata  Jun 10, 2009