I have some code that starts another activity based on a menu item
selection:

    public boolean onOptionsItemSelected( MenuItem item ) {
        Log.d( TAG, "onOptionsItemSelected(): entering..." );
        //...
        switch ( item.getItemId() ) {
            //...
            case MENU_REINIT:
                Log.d( TAG, "onOptionsItemSelected(): MENU_REINIT" );
                startActivity( new Intent( this, InitWebAct.class ) );
                break;
            case MENU_ACCT:
                Log.d( TAG, "onOptionsItemSelected(): MENU_ACCT" );
                startActivity( new Intent( this, AcctAct.class ) );
                break;
            //..

The MENU_REINIT and MENU_ACCT cases are coded identically.  The REINIT
case works everywhere.  The MENU_ACCT case works in the emulator, but
crashes on my real T-Mobile G1 running Android 1.5.  Both activities
are similarly declared in the Android manifest file:

    <activity android:name=".AcctAct"
              android:label="@string/c_acct"
              >
    </activity>
    ...
    <activity android:name=".InitWebAct"
              android:label="@string/t_init"
              >
    </activity>

Trying to get that AcctAct activity started on the physical device
crashes with an ActivityNotFoundException:

    ...
    09-30 15:18:03.697 D/oma.ClubsAct( 3448): onOptionsItemSelected():
entering...
    09-30 15:18:03.697 D/oma.ClubsAct( 3448): onOptionsItemSelected():
MENU_ACCT
    09-30 15:18:03.697 I/ActivityManager(   56): Starting activity:
Intent { comp={com.orgmob/com.orgmob.AcctAct} }
    09-30 15:18:03.697 D/AndroidRuntime( 3448): Shutting down VM
    09-30 15:18:03.697 W/dalvikvm( 3448): threadid=3: thread exiting
with uncaught exception (group=0x4000fe70)
    09-30 15:18:03.697 E/AndroidRuntime( 3448): Uncaught handler:
thread main exiting due to uncaught exception
    09-30 15:18:03.897 E/AndroidRuntime( 3448):
android.content.ActivityNotFoundException: Unable to find explicit
activity class {com.orgmob/com.orgmob.AcctAct}; have you declared this
activity in your AndroidManifest.xml?
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
android.app.Instrumentation.checkStartActivityResult
(Instrumentation.java:1480)
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
android.app.Instrumentation.execStartActivity(Instrumentation.java:
1454)
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
android.app.Activity.startActivityForResult(Activity.java:2656)
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
android.app.Activity.startActivity(Activity.java:2700)
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
com.orgmob.ClubsAct.onOptionsItemSelected(ClubsAct.java:344)
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
android.app.Activity.onOptionsItemSelected(Activity.java:2197)
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
com.orgmob.ClubAct.onOptionsItemSelected(ClubAct.java:966)
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
android.app.Activity.onMenuItemSelected(Activity.java:2085)
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected
(PhoneWindow.java:820)
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:
139)
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
com.android.internal.view.menu.MenuBuilder.performItemAction
(MenuBuilder.java:813)
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
com.android.internal.view.menu.ExpandedMenuView.invokeItem
(ExpandedMenuView.java:89)
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
com.android.internal.view.menu.ExpandedMenuView.onItemClick
(ExpandedMenuView.java:93)
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
android.widget.AdapterView.performItemClick(AdapterView.java:283)
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
android.widget.ListView.performItemClick(ListView.java:3132)
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
android.widget.AbsListView$PerformClick.run(AbsListView.java:1620)
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
android.os.Handler.handleCallback(Handler.java:587)
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
android.os.Handler.dispatchMessage(Handler.java:92)
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
android.os.Looper.loop(Looper.java:123)
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
android.app.ActivityThread.main(ActivityThread.java:3948)
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
java.lang.reflect.Method.invokeNative(Native Method)
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
java.lang.reflect.Method.invoke(Method.java:521)
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:782)
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
    09-30 15:18:03.897 E/AndroidRuntime( 3448):         at
dalvik.system.NativeStart.main(Native Method)
    09-30 15:18:03.907 I/Process (   56): Sending signal. PID: 3448
SIG: 3
    09-30 15:18:03.907 I/dalvikvm( 3448): threadid=7: reacting to
signal 3
    09-30 15:18:03.937 I/dalvikvm( 3448): Wrote stack trace to '/data/
anr/traces.txt'
    ...

I've upgraded my Android SDK from 1.5 to 1.6; it still fails the same
way.

>From the "adb bugreport" output, there's the corroboration from the
event log that the menu item was pressed, but not much more helpful
information:

    ------ EVENT LOG ------
    ...
    09-30 15:17:58.507 I/menu_opened( 3448): 0
    09-30 15:18:01.927 I/dvm_gc_info( 3448):
[8030594805266953502,-9058283148088055766,-4014252596544235525,7370486]
    09-30 15:18:03.697 I/menu_item_selected( 3448): [0,Account]
    09-30 15:18:06.967 I/dvm_gc_madvise_info( 3448): [335872,299008]
    ...

Can anybody shed any light on this?  I've spent quite a bit of time on
this and am inclined to file a bug report at this point.  I can see a
reference to the allegedly missing class in the classes.dex file
inside the APK and the code works properly in the emulator.  I haven't
been able to find anything like this, so if there is, an RTFM pointer
will be humbly accepted.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to