Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Mobile Development > BOOK: Professional Android 2 Application Development
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Professional Android 2 Application Development
This is the forum to discuss the Wrox book Professional Android 2 Application Development, 2nd Edition by Reto Meier; ISBN: 978-0-470-56552-0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Android 2 Application Development section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 29th, 2010, 09:05 PM
Registered User
 
Join Date: Mar 2010
Posts: 13
Thanks: 1
Thanked 0 Times in 0 Posts
Default Unable to run code chapter 9, 10, 13

I am running an avd that supports api 2.1 but always receives a weird forced quit when i start running the codes. Chapter 5's code has no such problem. I wonder if there is something special about running the code for chapter 9 and 10 for Earthquake project.
Reply With Quote
  #2 (permalink)  
Old March 30th, 2010, 10:18 AM
Registered User
 
Join Date: Mar 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You need to look at your logcat in order to figure out what is triggering the force quit. I've only run bits and pieces of the Earthquake application so I couldn't say for sure if I've run into the same trouble that you're having.

Maybe there should be a chapter just on debugging.
Reply With Quote
  #3 (permalink)  
Old March 30th, 2010, 12:02 PM
Registered User
 
Join Date: Mar 2010
Posts: 13
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I basically ran the code downloaded from this website, but apparently there are a lot of small errors in the code. I think there should be an error page on the website to help people fixing those small errors.
Reply With Quote
  #4 (permalink)  
Old April 4th, 2010, 06:52 AM
Reto's Avatar
Wrox Author
Points: 287, Level: 5
Points: 287, Level: 5 Points: 287, Level: 5 Points: 287, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2008
Location: London, United Kingdom
Posts: 61
Thanks: 1
Thanked 7 Times in 6 Posts
Default

That's odd -- you certainly shouldn't be seeing force close on those later chapters -- could you provide a little more info on what errors you're seeing in the code? I can update the samples and add the errors to the books errata site, but I need your help to figure out what the errors are first :)

Could you include the contents of your logcat output after the force quit?
__________________
Reto Meier

Author, "Professional Android 4 Application Development", Wrox, ©2012, 2010, 2008
@retomeier
Reply With Quote
  #5 (permalink)  
Old April 4th, 2010, 09:34 AM
Registered User
 
Join Date: Mar 2010
Posts: 13
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Sure, I am willing to cooperate as much as possible since I am curious about why as well...

The code is from Professional Android 2 Code Example Projects.zip
Project Name: Chapter 9 Earthquake 4
My avd is running Google api level 7 platform 2.1

Error message on the screen of android simulator: Sorry! The application Earthquake (process com.paad.earthquake) has stopped unexpectedly. Please try again.
Force close


Logcat errors:

04-04 09:32:31.469: ERROR/AndroidRuntime(293): ERROR: thread attach failed

04-04 09:32:34.900: ERROR/gralloc(52): [unregister] handle 0x368728 still locked (state=40000001)

04-04 09:32:35.130: ERROR/Database(300): Failure 1 (near ",": syntax error) on 0x139460 when preparing 'create table earthquakes (_id integer primary key autoincrement, date INTEGER, details TEXT, latitude FLOAT, longitude FLOAT, magnitude FLOAT), link TEXT);'.

04-04 09:32:34.900: ERROR/gralloc(52): [unregister] handle 0x368728 still locked (state=40000001)
04-04 09:32:35.130: ERROR/Database(300): Failure 1 (near ",": syntax error) on 0x139460 when preparing 'create table earthquakes (_id integer primary key autoincrement, date INTEGER, details TEXT, latitude FLOAT, longitude FLOAT, magnitude FLOAT), link TEXT);'.


Full logcat logs:

04-04 09:31:24.139: DEBUG/AndroidRuntime(261): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
04-04 09:31:24.149: DEBUG/AndroidRuntime(261): CheckJNI is ON
04-04 09:31:24.350: DEBUG/AndroidRuntime(261): --- registering native functions ---
04-04 09:31:24.670: DEBUG/ddm-heap(261): Got feature list request
04-04 09:31:25.109: DEBUG/AndroidRuntime(261): Shutting down VM
04-04 09:31:25.119: DEBUG/dalvikvm(261): DestroyJavaVM waiting for non-daemon threads to exit
04-04 09:31:25.119: DEBUG/dalvikvm(261): DestroyJavaVM shutting VM down
04-04 09:31:25.119: DEBUG/dalvikvm(261): HeapWorker thread shutting down
04-04 09:31:25.119: DEBUG/dalvikvm(261): HeapWorker thread has shut down
04-04 09:31:25.119: DEBUG/jdwp(261): JDWP shutting down net...
04-04 09:31:25.119: INFO/dalvikvm(261): Debugger has detached; object registry had 1 entries
04-04 09:31:25.139: DEBUG/dalvikvm(261): VM cleaning up
04-04 09:31:25.149: ERROR/AndroidRuntime(261): ERROR: thread attach failed
04-04 09:31:25.169: DEBUG/dalvikvm(261): LinearAlloc 0x0 used 628628 of 5242880 (11%)
04-04 09:31:25.630: DEBUG/AndroidRuntime(269): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
04-04 09:31:25.630: DEBUG/AndroidRuntime(269): CheckJNI is ON
04-04 09:31:25.850: DEBUG/AndroidRuntime(269): --- registering native functions ---
04-04 09:31:26.179: DEBUG/ddm-heap(269): Got feature list request
04-04 09:31:26.630: DEBUG/ActivityManager(52): Uninstalling process com.paad.earthquake
04-04 09:31:26.630: DEBUG/ActivityManager(52): Force removing process ProcessRecord{43dd1f88 252:com.paad.earthquake/10027} (com.paad.earthquake/10027)
04-04 09:31:26.630: INFO/Process(52): Sending signal. PID: 252 SIG: 9
04-04 09:31:26.710: INFO/UsageStats(52): Unexpected resume of com.android.launcher while already resumed in com.paad.earthquake
04-04 09:31:26.750: INFO/ActivityManager(52): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.paad.earthquake/.Earthquake }
04-04 09:31:26.760: DEBUG/ActivityManager(52): Received spurious death notification for thread android.os.BinderProxy@43dd4a58
04-04 09:31:26.770: DEBUG/AndroidRuntime(269): Shutting down VM
04-04 09:31:26.770: DEBUG/dalvikvm(269): DestroyJavaVM waiting for non-daemon threads to exit
04-04 09:31:26.780: DEBUG/dalvikvm(269): DestroyJavaVM shutting VM down
04-04 09:31:26.780: DEBUG/dalvikvm(269): HeapWorker thread shutting down
04-04 09:31:26.780: DEBUG/dalvikvm(269): HeapWorker thread has shut down
04-04 09:31:26.780: DEBUG/jdwp(269): JDWP shutting down net...
04-04 09:31:26.790: INFO/dalvikvm(269): Debugger has detached; object registry had 1 entries
04-04 09:31:26.790: DEBUG/dalvikvm(269): VM cleaning up
04-04 09:31:26.850: ERROR/AndroidRuntime(269): ERROR: thread attach failed
04-04 09:31:26.880: DEBUG/dalvikvm(269): LinearAlloc 0x0 used 638596 of 5242880 (12%)
04-04 09:31:27.020: WARN/InputManagerService(52): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$ Proxy@43de6898
04-04 09:31:27.040: INFO/ActivityManager(52): Start proc com.paad.earthquake for activity com.paad.earthquake/.Earthquake: pid=276 uid=10027 gids={3003}
04-04 09:31:27.359: DEBUG/ddm-heap(276): Got feature list request
04-04 09:31:27.520: WARN/ActivityThread(276): Application com.paad.earthquake is waiting for the debugger on port 8100...
04-04 09:31:27.550: INFO/System.out(276): Sending WAIT chunk
04-04 09:31:27.581: INFO/dalvikvm(276): Debugger is active
04-04 09:31:27.590: INFO/ARMAssembler(52): generated scanline__00000077:03010104_00000004_00000000 [ 22 ipp] (41 ins) at [0x37ab70:0x37ac14] in 1176000 ns
04-04 09:31:27.760: INFO/System.out(276): Debugger has connected
04-04 09:31:27.760: INFO/System.out(276): waiting for debugger to settle...
04-04 09:31:27.960: INFO/System.out(276): waiting for debugger to settle...
04-04 09:31:28.159: INFO/System.out(276): waiting for debugger to settle...
04-04 09:31:28.360: INFO/System.out(276): waiting for debugger to settle...
04-04 09:31:28.570: INFO/System.out(276): waiting for debugger to settle...
04-04 09:31:28.770: INFO/System.out(276): waiting for debugger to settle...
04-04 09:31:28.976: INFO/System.out(276): waiting for debugger to settle...
04-04 09:31:29.177: INFO/System.out(276): waiting for debugger to settle...
04-04 09:31:29.379: INFO/System.out(276): waiting for debugger to settle...
04-04 09:31:29.583: INFO/System.out(276): waiting for debugger to settle...
04-04 09:31:29.787: INFO/System.out(276): waiting for debugger to settle...
04-04 09:31:29.990: INFO/System.out(276): waiting for debugger to settle...
04-04 09:31:30.199: INFO/System.out(276): debugger has settled (1434)
04-04 09:31:30.350: INFO/ActivityThread(276): Publishing provider com.paad.provider.earthquake: com.paad.earthquake.EarthquakeProvider
04-04 09:31:30.590: ERROR/Database(276): Failure 1 (near ",": syntax error) on 0x128dd0 when preparing 'create table earthquakes (_id integer primary key autoincrement, date INTEGER, details TEXT, latitude FLOAT, longitude FLOAT, magnitude FLOAT), link TEXT);'.
04-04 09:31:36.768: WARN/ActivityManager(52): Launch timeout has expired, giving up wake lock!
04-04 09:31:37.473: WARN/ActivityManager(52): Activity idle timeout for HistoryRecord{43de2fb8 com.paad.earthquake/.Earthquake}
Reply With Quote
  #6 (permalink)  
Old April 7th, 2010, 10:19 AM
Reto's Avatar
Wrox Author
Points: 287, Level: 5
Points: 287, Level: 5 Points: 287, Level: 5 Points: 287, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2008
Location: London, United Kingdom
Posts: 61
Thanks: 1
Thanked 7 Times in 6 Posts
Default

Thanks!

There's a typo that somehow managed to sneak through in both the code and the examples.

Line 191 of the EarthquakeProvider class (introduced on Page 232) has a superfluous ")". It should read:

Code:
+ KEY_MAGNITUDE + " FLOAT, "
NOT

Code:
+ KEY_MAGNITUDE + " FLOAT), "
I'll update the downloadable code samples ASAP and add this to the book's errata page. Thanks for letting me know!
__________________
Reto Meier

Author, "Professional Android 4 Application Development", Wrox, ©2012, 2010, 2008
@retomeier
Reply With Quote
The Following 2 Users Say Thank You to Reto For This Useful Post:
vtrandal (October 31st, 2010)
  #7 (permalink)  
Old April 7th, 2010, 05:02 PM
Registered User
 
Join Date: Mar 2010
Posts: 13
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Yea, it seems to work.

By the way, some of the projects like the ones for Chapter 7 and Chapter 9, have multiple versions, like Chapter 9 has 1 2 3 4 for Earthquake, do you know what's the difference between them?
Reply With Quote
  #8 (permalink)  
Old April 9th, 2010, 10:24 AM
Registered User
 
Join Date: Apr 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am getting the same errors with the Bluetooth texting example in Chapter 13, i.e., the project Force Quits when it is run on my device as well as on the emulator (I am aware that the emulator cannot do bluetooth, but I was just trying it there to see if it would compile).

How can I access this "Logcat" information in order to post it here? I searched the eclipse help for "logcat" and came up with nothing.

Please help. Thanks.
Reply With Quote
  #9 (permalink)  
Old April 9th, 2010, 10:49 AM
Registered User
 
Join Date: Apr 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I found the logcat information pane finally under window->show view->logcat. Why that is not in the help is beyond me.

At any rate, here is the log I am getting when I try to run it on my device. My device, BTW, is a Nexus One with Android 2.1 update1 running on it.

04-09 10:48:35.213: WARN/WindowManager(52): Key dispatching timed out sending to <null>
04-09 10:48:35.213: WARN/WindowManager(52): Dispatch state: null
04-09 10:48:35.213: INFO/WindowManager(52): focus null mToken is null at event dispatch!
04-09 10:48:35.213: WARN/WindowManager(52): Current state: {{KeyEvent{action=0 code=82 repeat=0 meta=0 scancode=229 mFlags=8} to null @ 1270824515216 lw=null lb=null fin=true gfw=true ed=true tts=0 wf=false fp=false mcf=null}}
04-09 10:48:35.213: WARN/WindowManager(52): Continuing to wait for key to be dispatched
04-09 10:48:40.222: WARN/WindowManager(52): Key dispatching timed out sending to <null>
04-09 10:48:40.222: WARN/WindowManager(52): Dispatch state: null
04-09 10:48:40.222: INFO/WindowManager(52): focus null mToken is null at event dispatch!
04-09 10:48:40.222: WARN/WindowManager(52): Current state: {{KeyEvent{action=0 code=82 repeat=0 meta=0 scancode=229 mFlags=8} to null @ 1270824520225 lw=null lb=null fin=true gfw=true ed=true tts=0 wf=false fp=false mcf=null}}
04-09 10:48:40.222: WARN/WindowManager(52): Continuing to wait for key to be dispatched
Reply With Quote
  #10 (permalink)  
Old June 2nd, 2010, 03:59 AM
Registered User
 
Join Date: Jun 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

there could be an error in the way EarthquakeService.java reads the preferences (lines 191 - 205).

IMHO, reading of preferences should be similar to lines 210 - 212 of Earthquake.java, because the values are stored in Preferences as the "real values", not index values.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to run Chapter 2 Example tkachuk BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio 6 August 2nd, 2009 11:37 PM
LINQ: Chapter 13, the first example cannot be run clark BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 6 January 15th, 2009 08:41 AM
Missing Source Code for Chapters 2-10, 12, 13, 15? haroldbingo BOOK: Beginning JavaServer Pages 5 February 16th, 2008 11:32 AM
How to run the chapter 10 (acegi) sample code? dleal BOOK: Professional Java Development with the Spring Framework 0 June 28th, 2006 10:50 AM
unable to run ch 10 examples jgtez JSP Basics 0 February 24th, 2004 09:22 PM



All times are GMT -4. The time now is 03:48 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.