Tutorial 3

3 views
Skip to first unread message

cbeast

unread,
Mar 11, 2010, 9:44:17 AM3/11/10
to cw-android
I'm a total newbie to android and working my way through the Android
Programming Tutorials book. Doing OK, but I've hit a wall on the
Tutorial 3, where after adding the Radio Group I keep getting a
Stopped unexpectedly error. I've done a diff of the main.xml in the
online code and mine and nothing is popping out at me. Ideas? Below
is my main.xml and some output from adb logcat. Thank you!
===========================================================================
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:orientation ="vertical"
android:layout_width ="fill_parent"
android:layout_height ="fill_parent"
android:stretchColumns="1"
>
<TableRow>
<TextView android:text="Name:" />
<EditText android:id ="@+id/name" />
</TableRow>

<TableRow>
<TextView android:text="Address:" />
<EditText android:id ="@+id/addr" />
</TableRow>

<TableRow>
<TextView android:text="Type:" />
<RadioGroup android:id="@+id/types"
>
<RadioButton android:id="@+id/take_out"
android:text="Take-Out"
/>
<RadioButton android:id="@+id/sit_down"
android:text="Sit-Down"
/>
<RadioButton android:id="@+id/delivery"
android:text="Delivery"
/>
</RadioGroup>
</TableRow>
<Button android:id="@+id/save"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Save"
/>
</TableLayout>
=============================================================================

I/ActivityManager( 565): Starting activity: Intent
{ action=android.intent.action.MAIN
categories={android.intent.category.LAUNCHER} flags=0x10200000
comp={apt.tutorial/apt.tutorial.LunchList} }
I/ActivityManager( 565): Start proc apt.tutorial for activity
apt.tutorial/.LunchList: pid=687 uid=10019 gids={}
D/AndroidRuntime( 687): Shutting down VM
W/dalvikvm( 687): threadid=3: thread exiting with uncaught exception
(group=0x4000fe70)
E/AndroidRuntime( 687): Uncaught handler: thread main exiting due to
uncaught exception
E/AndroidRuntime( 687): java.lang.RuntimeException: Unable to start
activity ComponentInfo{apt.tutorial/apt.tutorial.LunchList}:
java.lang.ClassCastE
xception: android.widget.RadioGroup
E/AndroidRuntime( 687): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2268)
E/AndroidRuntime( 687): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2284)
E/AndroidRuntime( 687): at android.app.ActivityThread.access
$1800(ActivityThread.java:112)
E/AndroidRuntime( 687): at android.app.ActivityThread
$H.handleMessage(ActivityThread.java:1692)
E/AndroidRuntime( 687): at
android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 687): at android.os.Looper.loop(Looper.java:
123)
E/AndroidRuntime( 687): at
android.app.ActivityThread.main(ActivityThread.java:3948)
E/AndroidRuntime( 687): at
java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 687): at
java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 687): at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:782)
E/AndroidRuntime( 687): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
E/AndroidRuntime( 687): at
dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 687): Caused by: java.lang.ClassCastException:
android.widget.RadioGroup
E/AndroidRuntime( 687): at
apt.tutorial.LunchList.onCreate(LunchList.java:22)
E/AndroidRuntime( 687): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1123)
E/AndroidRuntime( 687): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2231)
E/AndroidRuntime( 687): ... 11 more
I/Process ( 565): Sending signal. PID: 687 SIG: 3
I/dalvikvm( 687): threadid=7: reacting to signal 3
I/dalvikvm( 687): Wrote stack trace to '/data/anr/traces.txt'
I/ARMAssembler( 565): generated
scanline__00000077:03515104_00000000_00000000 [ 27 ipp] (41 ins) at
[0x201510:0x2015b4] in 589460 ns
I/ARMAssembler( 565): generated
scanline__00000077:03515104_00001001_00000000 [ 64 ipp] (84 ins) at
[0x2015b8:0x201708] in 1274463 ns
I/Process ( 687): Sending signal. PID: 687 SIG: 9
I/ActivityManager( 565): Process apt.tutorial (pid 687) has died.
W/InputManagerService( 565): Window already focused, ignoring focus
gain of: com.android.internal.view.IInputMethodClient$Stub
$Proxy@436c6048
W/KeyCharacterMap( 607): No keyboard for id 0
W/KeyCharacterMap( 607): Using default keymap: /system/usr/keychars/
qwerty.kcm.bin

Mark Murphy

unread,
Mar 11, 2010, 9:47:07 AM3/11/10
to cw-an...@googlegroups.com
cbeast wrote:
> I'm a total newbie to android and working my way through the Android
> Programming Tutorials book. Doing OK, but I've hit a wall on the
> Tutorial 3, where after adding the Radio Group I keep getting a
> Stopped unexpectedly error. I've done a diff of the main.xml in the
> online code and mine and nothing is popping out at me. Ideas? Below
> is my main.xml and some output from adb logcat. Thank you!

Did you do a Force Clean (Eclipse) or ant clean (command-line), per
pages 24-25 (in Version 2.0 of the book)?

ClassCastExceptions are frequently triggered by resource IDs getting out
of sync, which the above steps should clear up. Certainly ant clean works.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Training in NYC: 1-2 May 2010: http://guruloft.com

cbeast

unread,
Mar 11, 2010, 9:58:45 AM3/11/10
to cw-android
No, I hadn't. I actually have the first edition of the book.
I don't see clean when calling ant help, is that something I need to
add?

Thank you so much for your help,
Chris

yeradis

unread,
Mar 11, 2010, 10:11:23 AM3/11/10
to cw-an...@googlegroups.com
Hello

To clean a project and force a sync of resource

on Eclipse .... choose menu Project/Clean

Bye

Yeradis P. Barbosa Marrero
Analista - Programador de Sistemas
http://www.yeradis.com
http://profile.yeradis.com
http://www.linkedin.com/in/yeradis


Nota:
Este mensaje, y en su caso, cualquier fichero anexo al mismo, puede
contener informacion confidencial, siendo para uso exclusivo del
destinatario, quedando prohibida su divulgacion copia o
distribucion a terceros sin la autorizacion expresa del remitente.
Si Vd. ha recibido este mensaje erroneamente, se ruega lo
notifique al remitente y proceda a su borrado.
Gracias por su colaboracion.

This message (including any attachments) may contain confidential
information. It is intended for use by the recipient only. Any
dissemination, copying or distribution to third parties without
the express consent of the sender is strictly prohibited.
If you have received this message in error, please delete it
immediately and notify the sender.
Thank you for your collaboration.



--
You received this message because you are subscribed to the Google Groups "cw-android" group.
To post to this group, send email to cw-an...@googlegroups.com.
To unsubscribe from this group, send email to cw-android+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cw-android?hl=en.


cbeast

unread,
Mar 11, 2010, 10:13:51 AM3/11/10
to cw-android
Thanks, but I'm actually not using Eclipse. I'm working command line
like Mark is doing in the book.

yeradis

unread,
Mar 11, 2010, 10:24:14 AM3/11/10
to cw-an...@googlegroups.com
Oh , sorry then :S

Sin más....
Me despido


Yeradis P. Barbosa Marrero
Analista - Programador de Sistemas
http://www.yeradis.com
http://profile.yeradis.com
http://www.linkedin.com/in/yeradis


Nota:
Este mensaje, y en su caso, cualquier fichero anexo al mismo, puede
contener informacion confidencial, siendo para uso exclusivo del
destinatario, quedando prohibida su divulgacion copia o
distribucion a terceros sin la autorizacion expresa del remitente.
Si Vd. ha recibido este mensaje erroneamente, se ruega lo
notifique al remitente y proceda a su borrado.
Gracias por su colaboracion.

This message (including any attachments) may contain confidential
information. It is intended for use by the recipient only. Any
dissemination, copying or distribution to third parties without
the express consent of the sender is strictly prohibited.
If you have received this message in error, please delete it
immediately and notify the sender.
Thank you for your collaboration.


On Thu, Mar 11, 2010 at 16:13, cbeast <cbu...@gmail.com> wrote:
Thanks, but I'm actually not using Eclipse.  I'm working command line
like Mark is doing in the book.

--

Mark Murphy

unread,
Mar 11, 2010, 10:50:57 AM3/11/10
to cw-an...@googlegroups.com
cbeast wrote:
> Thanks, but I'm actually not using Eclipse. I'm working command line
> like Mark is doing in the book.

That was added in Android 1.6 or so.

Just delete the bin/ and gen/ directories of your project -- that is all
ant clean really does.

_Android Programming Tutorials_ Version 2.0 Available!

cbeast

unread,
Mar 11, 2010, 10:59:18 AM3/11/10
to cw-android
Awesome! That did it - I could have sworn I tried that already, but
deleting the the two directories worked!
Thanks again for your help.

cbeast

unread,
Mar 11, 2010, 11:53:19 AM3/11/10
to cw-android
Do you think that is I built a new AVD that is 1.6 or later I would
avoid this problem on the rest of the tutorials?

Mark Murphy

unread,
Mar 11, 2010, 1:44:20 PM3/11/10
to cw-an...@googlegroups.com
cbeast wrote:
> Do you think that is I built a new AVD that is 1.6 or later I would
> avoid this problem on the rest of the tutorials?

No, it will crop up from time to time, particularly when you add resources.

Android Training in NYC: 10-11 April 2010: http://guruloft.com

Reply all
Reply to author
Forward
0 new messages