Errata

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.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
PDF Page p35
Running the MJAndroid Code

my MJAndroid project also encounter the error ?The application com.microjobsinc.mjandroid (process com.microjobsinc.mjandroid) has stopped unexpectedly. Please try again. [Force close]?

and the same 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 is
IDE : eclipse-java-galileo-SR1-win32
SDK : android-sdk_r3-windows
Platform:Android 1.6
API-level:4

My platform is version 1.6(not v1.1),but I also can't run the project.

Jean  Nov 29, 2009 
Other Digital Version chapter3(kindle version)
apk installation instructions

After hours of trying to fix the runtime error after installing the sample MJAndroid.apk file that came with the book, I finally came up with the solution thanks to the help of a previous errata post. (Using Google API level 5) When trying to install the example .apk file that came with the book use the MJAndroid.apk file included in one of the tarballs, not the zip file. The tarball I used was: example_android.tar.gz. Otherwise the instructions in the book were accurate.

jason  Jan 31, 2010 
Other Digital Version NA
Unable to run MJAndroid on Nexus One with Froyo (FRF91)

Using the downloadable example here, http://examples.oreilly.com/9780596521479/MJAndroid.zip, when I use adb to install the included apk file on my Nexus One (build FRF91), I get this error when I try to click on a job in the map and the app force-quits:

D/AndroidRuntime( 964): Shutting down VM
W/dalvikvm( 964): threadid=1: thread exiting with uncaught exception (group=0x4001d7f0)
E/AndroidRuntime( 964): FATAL EXCEPTION: main
E/AndroidRuntime( 964): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.microjobsinc.mjandroid/com.microjobsinc.mjandroid.MicroJobsDetail}: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
E/AndroidRuntime( 964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
E/AndroidRuntime( 964): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
E/AndroidRuntime( 964): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
E/AndroidRuntime( 964): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
E/AndroidRuntime( 964): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 964): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 964): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 964): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 964): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 964): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 964): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 964): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 964): Caused by: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
E/AndroidRuntime( 964): at android.database.AbstractCursor.checkPosition(AbstractCursor.java:580)
E/AndroidRuntime( 964): at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:214)
E/AndroidRuntime( 964): at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:41)
E/AndroidRuntime( 964): at com.microjobsinc.mjandroid.MicroJobsDatabase$JobDetailCursor.getColTitle(MicroJobsDatabase.java:85)
E/AndroidRuntime( 964): at com.microjobsinc.mjandroid.MicroJobsDetail.onCreate(MicroJobsDetail.java:71)
E/AndroidRuntime( 964): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime( 964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
E/AndroidRuntime( 964): ... 11 more
W/ActivityManager( 81): Force finishing activity com.microjobsinc.mjandroid/.MicroJobsDetail
W/ActivityManager( 81): Force finishing activity com.microjobsinc.mjandroid/.MicroJobs
W/ActivityManager( 81): Activity pause timeout for HistoryRecord{44cf2e50 com.microjobsinc.mjandroid/.MicroJobsDetail}
V/RenderScript_jni( 157): surfaceCreated
V/RenderScript_jni( 157): surfaceChanged

bouncing  Jul 11, 2010 
14.1

I was trying to implement the simple dialing example 14.1

I kept getting an error in the emulator
something like 'the application was forced to quit'
I never got to the display screen illustrated in the book

also the debugging sequence would terminate on the last step

I downloaded the examples from the website and I copied and pasted from the book. Neither worked.


Then I remembered your earlier section on permissions. Your manifest.xml for this example never asked permission to make telephone calls. I added this permission line to the xml and the example then worked.

<uses-permission android:name="android.permission.CALL_PHONE" />

The good news is that your earlier section on permissions seemed to have the desired impact. The bad news is that your example at the book's website is incomplete and the text in the book needs a warning about permissions.

thanks

swilson  Aug 23, 2009 
15
Item #4: Install Android SDK

Neither in the Safari Books Online version nor in the updated Chapter 2 available from the publisher's site do you ever say to install version 1.6 of the SDK. You do mention in Item #2 (installing Eclipse) of the updated Chapter 2 that SDK version 1.6 is compatible with Eclipse version 3.5, but that's as close as it comes. So the comment, "We find in [sic] surprising that readers download a version of the Android SDK that is clearly a different version than the one discussed in the book, ..." is disingenuous. You may indeed discuss SDK v. 1.6, but not in the place it matters the most: installation & setup.

kajaco2  May 21, 2010 
Printed Page 16
Update Environment Variables (and configuring your tools)

Add to thise section:

1. In the environment variables, you need to add a path inclusion to the Java bin directory so you can use the keytool and jarsigner for chapter 7. (Which you need to jump to in order to use the exmaples, unless you, unlike me, can find and download a Google-API-included Android setup for ADK 1.1..)

2. You might also need to include a description for JAVA_HOME too. (I'm not sure if Eclipse takes care of that or not as per the description at http://developer.android.com/guide/publishing/app-signing.html#setup.)

3. It's unclear how to use a Windows tool to decompress the only working example, a tar.gz file, in Windows, so I used Cygwin's tar -xzf (file.tar.gz) on the examples that you're to download for the book. However, there may be a path or something that needs to be setup to arrive at some other some other tool. ???

StephanWarren  Dec 19, 2009 
Printed Page 30
Top

I could be missing something here, but I cannot find the source code that accompanies this book. I registered and spend 20 minutes digging around for it.

Also - regarding environment variables on page 16, please print the PATH variable syntax exactly as it should read.

Thanks

Dimitri Darras  Jul 08, 2010 
Printed Page 30
1st paragraph: downloading the MJAndroid

there is no "Download MJAndroid" link on the book's web page:
http://www.oreilly.com/catalog/9780596521479

So I cannot download the source code. Is it just me not able to find the link or the link is actually removed from the page?

Frank  Jul 25, 2010 
Printed Page 30
Second paragraph

When loading the MJAndroid project into Eclipse I get 3 errors in the R.java area once the project is loaded.
Since I am new to Android development, how would I resolve these problems? Does anyone else have these issues?

1. Description Resource Path Location Type
Project has no default.properties file! Edit the project properties to set one. MJAndroid Unknown Android Target Problem

2. Description Resource Path Location Type
The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project MJAndroid Unknown Java Problem

3. Description Resource Path Location Type
The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files R.java /MJAndroid/src/com/microjobsinc/mjandroid line 1 Java Problem

Anonymous  Jan 12, 2011 
Other Digital Version 33 ff
Code Sample of MicroJobs app

I have tried the MicroJobs app on my new Motorola Milestone (=Droid) running Android 2.0 and found out that the line

Debug.startMethodTracing("x");

in MicroJobs.onCreate() causes the app to hang immediately after launch. From the LogCat:

"Unable to open trace file '/sdcard/x.trace': Permission denied"

12-28 20:56:10.788: ERROR/AndroidRuntime(2672): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.microjobsinc.mjandroid/com.microjobsinc.mjandroid.MicroJobs}: java.lang.RuntimeException: file open failed


After commenting the line the app worked, but didn?t show the map.

I got a NullPointer in com.google.android.maps.MapController.animateTo().

Sophia de Laradio  Dec 28, 2009 
Printed Page 35
Boxed Text

The author/editor's glib replies to several questions about problems with installing and running the .apk are very annoying. As a previous comment said:

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."

I purchased this book from Amazon and there will be no problems in returning this book and getting my money back.

Elwood Hunt  Oct 19, 2009 
Printed Page 35
Running the MJAndroid Code

There must be some way to install the map API key that I can understand.

I start the emulator in a cmd window as:

C:\Android\android-sdk-windows\tools>emulator.exe -avd AVD-1.5.0-API-3
And the emulator launches.

If I still have Eclipse running, and I launch the adb, I get:

C:\Users\stephan\.android\avd\AVD-1.5.0-API-3.avd>c:\Android\android-sdk-windows\tools\adb.exe install C:\Android\workspace\MJAndroid\bin\MJAndroid.apk
104 KB/s (71506 bytes in 0.668s)
Can't dispatch DDM chunk 46454154: no handler defined
Can't dispatch DDM chunk 4d505251: no handler defined
pkg: /data/local/tmp/MJAndroid.apk
Failure [INSTALL_FAILED_MISSING_SHARED_LIBRARY]

If I terminate Eclipse (and re-start the emulator), I get something different:

C:\Users\stephan\.android\avd\AVD-1.5.0-API-3.avd>c:\Android\android-sdk-windows
\tools\adb.exe install c:\Android\workspace\MJAndroid\bin\MJAndroid.apk
155 KB/s (71506 bytes in 0.449s)
pkg: /data/local/tmp/MJAndroid.apk
Failure [INSTALL_FAILED_MISSING_SHARED_LIBRARY]


So what's going on? It seems that I'm missing the Google library, but I'm not entirely positive. I opened two cmd windows (and ensured that Eclipse was shut-down).

Then I did the following in the 1st cmd window:

C:\Android\android-sdk-windows\tools>android list targets
Available Android targets:
id: 1 or "android-2"
Name: Android 1.1
Type: Platform
API level: 2
Revision: 1
Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-P
id: 2 or "android-3"
Name: Android 1.5
Type: Platform
API level: 3
Revision: 1
Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-P
id: 3 or "android-4"
Name: Android 1.6
Type: Platform
API level: 4
Revision: 1
Skins: HVGA (default), QVGA, WVGA800, WVGA854
id: 4 or "android-5"
Name: Android 2.0
Type: Platform
API level: 5
Revision: 1
Skins: HVGA (default), QVGA, WQVGA400, WQVGA432, WVGA800, WVGA854
id: 5 or "android-6"
Name: Android 2.0.1
Type: Platform
API level: 6
Revision: 1
Skins: HVGA (default), QVGA, WQVGA400, WQVGA432, WVGA800, WVGA854
id: 6 or "Google Inc.:Google APIs:3"
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Revision: 3
Description: Android + Google APIs
Based on Android 1.5 (API level 3)
Libraries:
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: QVGA-P, HVGA-L, HVGA (default), QVGA-L, HVGA-P
id: 7 or "Google Inc.:Google APIs:4"
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Revision: 2
Description: Android + Google APIs
Based on Android 1.6 (API level 4)
Libraries:
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: WVGA854, HVGA (default), WVGA800, QVGA
id: 8 or "Google Inc.:Google APIs:5"
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Revision: 1
Description: Android + Google APIs
Based on Android 2.0 (API level 5)
Libraries:
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: WVGA854, WQVGA400, HVGA (default), WQVGA432, WVGA800, QVGA
id: 9 or "Google Inc.:Google APIs:6"
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Revision: 1
Description: Android + Google APIs
Based on Android 2.0.1 (API level 6)
Libraries:
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: WVGA854, WQVGA400, HVGA (default), WQVGA432, WVGA800, QVGA

--------
From what the pg 35 errata is telling me, I need to use 1.5 with Google's APIs -- or id = 6
-----
From the same cmd window:

C:\Android\android-sdk-windows\tools>android create avd -n my_android1.5 -t 6
Created AVD 'my_android1.5' based on Google APIs (Google Inc.)
-----

Next, from the 2nd cmd window:

c:\Android\android-sdk-windows\tools>c:\Android\android-sdk-windows\tools\adb.exe install c:\Android\workspace\MJAndroid\bin\MJAndroid.apk
984 KB/s (73593 bytes in 0.073s)
pkg: /data/local/tmp/MJAndroid.apk
Success

-----
I got lucky.

Now the issue I have is running the code on the emulator in Eclipse, I get:

[2009-12-16 22:25:50 - MJAndroid]WARNING: Application does not specify an API level requirement!
[2009-12-16 22:25:50 - MJAndroid]Device API version is 3 (Android 1.5)


StephanWarren  Dec 16, 2009 
Printed Page 35
MJAndroid.apk Import

In the anonymous errata post for printed on Page 35 "Boxout 'Running the MJAndroid code'", the author's comment is:

"I have run all of our applications, using a type 3 AVD"

Question #1: What is "type 3"? (Where does this come from? Does '3' refer to the SDK number? When I look up SDK #3, it's version 1.5 and SDK#2 is 1.1. Was this from some older documentation at)

In the post for oblongata on page 43 (PDF), you point out the correct download version.

Question #2: Why not delete the incorrect versions? It would save you and the readers time sorting out the issue. Why not add a zip version for Windows users (like me)?


StephanWarren  Dec 17, 2009 
Printed Page 35
box

I'm enjoying this book, but

1. there is no MJAndroid-1.0.0.apk in any of the downloads from the O'Reilly site,

2. previous errata postings on the errors have improved my experience a little bit. However, I can not load the MJAndroid.apk info my level 3 emulator as it claims I have a 2nd emulator already open. So I closed Eclipse on the off chance that might not solve the problem and it did not....sighhhhh....

3. Good news: I uploaded MJAndroid.apk to my server and performed an OTA download to the device and tah dah the appliation runs with the map key provided...thank you. I was even able to add a job to the Google site, "android tutor : to aid the drop in visitor to their loaction"

4. Bad news: MJAndroid.apk crashes intermittently requiring a force quit

I look forward to digging deeper into the pages to glean more.

Cheerio,

Steve Bull  Jan 03, 2010 
Printed Page 35
Running the MJAndroid Code

I also came across the same errors as others mentioned. However, I tracked it down to installing the Google API plugins into the AVD Manager.

The Google API's within the Android available packages require their licenses specifically accepted prior to loading.

Upon re-visting the available packages area and ticking the accept all box...the MJAndroid application installed with success and fired up inside an AVD built with Google APIs specified within the android app.

Hope this helps others as I have spent 3 days getting this going. I suppose I know a lot more about Android setup now as a result.

James Cooper  Aug 22, 2010 
PDF Page 43
Section 3.5.2

I am beginning to feel somewhat frustrated at trying to get MJAndroid to run, so I backtracked to AnroidUIDemo, which also didn't run, however that one was relatively easy to fix once I found the duplicate R.java file in src.
Now back to the main project which we need to work. I have removed and reinstalled it several times, here's where I am - without having touched anything yet and just wanting it to build/run:

[2009-08-19 16:12:36 - MJAndroid] no classfiles specified
[2009-08-19 16:12:36 - MJAndroid] Conversion to Dalvik format failed with error 1

Hopefully someone can clear that one up as the book makes no mention of issues other than the apk file when first running the project.

Thanks in advance

Lee Crampton  Aug 19, 2009 
PDF Page 43
3.5.2 Loading and Starting the Application

MicroJobs.java:134 will throw an exception on API 1.5 and higher:

Debug.startMethodTracing("x");

The Debug.StartMethodTracing() will write to the sdcard, which requires the following permission in the AndroidManifest.xml:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Casey Ballentine  Jan 16, 2010 
PDF Page 46
Downloading the MJAndroid Code

I'm Using Vista Business sp1 eclipse 3.5 android-sdk-windows-1.5_r3

Can upzip to workspace OK
After import and build before running Get 9 errors (red cout) Only 6 red markers ?

public class MicroJobsDatabase extends SQLiteOpenHelper
SQLiteOpenHelper cannot be resolved to a type

LIKEWISE
public static class EmployersCursor extends SQLiteCursor
private static class Factory implements SQLiteDatabase.CursorFactory
public static class JobDetailCursor extends SQLiteCursor
private static class Factory implements SQLiteDatabase.CursorFactory
public static class JobsCursor extends SQLiteCursor

There's a red marker for
private void execMultipleSQL(SQLiteDatabase db, String[] sql){
for( String s : sql )
if (s.trim().length()>0)
db.execSQL(s);
}
In package explorer not in java detail


MicroJobsDatabase.java
package com.microjobsinc.mjandroid;

import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteCursor;
import android.database.sqlite.SQLiteCursorDriver;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteQuery;
import android.util.Log;

Note source code marked EARLY_RELEASE_VERSION-20081222 Oreilly has it dated 12-Aug-2009
also some of it has SVN files with it.


Arthur M  Aug 15, 2009 
Printed Page 79
4th paragraph

Under the section "Time/Call" it is stated that the column is the quotient of the second column divided by the sum of the numbers in the sixth column.

This is incorrect. Where it is stated second column it should in fact read third column.

Geoff Newson  Jan 22, 2010 
Other Digital Version 95
"Running the MJAndroid" box

This is from the Android Market-downloadable ebook.

The text reads, "You can install the file into the emulator by..." and has an example command reading,

$ emulator

At least in the latest SDK, you have to specify an avd name. So for example,

$ emulator @foo

(Foo being a virtual device you created.)

bouncing  Jul 11, 2010 
Printed Page 166
Wiring Up the Controller code

I think it is a serious omission, in a book that teaches programming, to leave out necessary libraries that needs to be imported and even code.

In Example 10.4. Wiring up a button, not only is it not mentioned you need to add an import of the "import java.util.Random;" and "import android.widget.Button;"libraries, but also "Random rand = new Random();" before setting buttons to random numbers.

Ren? Feuerlein  Dec 24, 2010 
Printed Page 264
3rd paragraph

The book says:

*
As a result, our SayHello activity is launched because it has an Intent filter that matches the parameters we have set in this Intent object.
*

That would be true if we had set an Intent filter on the SayHello activitiy. Unfortunately there's no hint on the book where and how to do that. I got the example up and running extending the application's manifest with an appropriate filter:

<activity android:name=".SayHello" android:label="@string/app_name" android:exported="true" android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.example.greeting/vnd.example.greeting-text" />
</intent-filter>
</activity>

Stefan  Sep 16, 2009