Android programming: ArrayIndexOutOfBoundsException in ViewRoot.handleMessage

I had fought with this exception for a week:

Thread [<1> main] (Suspended (exception ArrayIndexOutOfBoundsException))
ViewRoot.handleMessage(Message) line: 1895
ViewRoot(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 130
ActivityThread.main(String[]) line: 3695
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 507
ZygoteInit$MethodAndArgsCaller.run() line: 842
ZygoteInit.main(String[]) line: 600
NativeStart.main(String[]) line: not available [native method]

When I saw the exception backtrace I tought that I was doing something wrong with my View hierarchy that was damaging the state of the ViewRoot instance.

Then I realized that I was actually accessing an array with an invalid index from an event handler that is actually called from the Android class android.view.core.ViewRoot!

Then I understood what was happening. I was using an array with an invalid index in a method that was called by the onTouch event handler!

So, the exception backtrace should be something like this:

Thread [<1> main] (Suspended (exception ArrayIndexOutOfBoundsException))
MyClassHere.myMethodHere() line: 123
...
...
ViewRoot.handleMessage(Message) line: 1895
ViewRoot(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 130
ActivityThread.main(String[]) line: 3695
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 507
ZygoteInit$MethodAndArgsCaller.run() line: 842
ZygoteInit.main(String[]) line: 600
NativeStart.main(String[]) line: not available [native method]

Why isn’t my class appearing in the backtrace? I don’t know!

So, remember that, when you have an Exception throwing from ViewRoot.handleMessage probably you are raising that exception from an event handler that is called from that method!

Android programming: ArrayIndexOutOfBoundsException in ViewRoot.handleMessage

Flash Builder and JBoss Tools 3.3

Let say you have Flash Builder and you would like to deploy your application on JBoss AS 7. Maybe you also want to control your JBoss from the IDE.

First of all you must have Flash Builder 4.6, because JBoss Tools 3.3 work only with Eclipse Indigo and only the latest Flash Builder is based on Indigo.

If you have Flash Builder 4.5 you must upgrade to the new release and you must uninstall the old one and install the new release.

When you are uninstalling Flash Builder 4.5 you want to uncheck the “Disable” option on the first screen, so that the uninstalling process do not delete your previous Flash Builder license.

https://leonardoce.files.wordpress.com/2011/12/wpid-flash_builder_disattiva.png

Now you can install the new Flash Builder release, it will migrate your previous settings.

When you have installed the new Flash Builder you must install the Eclipse J2EE tools. To install the J2EE tools you must add the Indigo update URL to your Flash Builder installation.

First of all select Install New Software from the Help menu in your Flash Builder installation and add to the update sites the Indigo Url, which is http://download.eclipse.org/releases/indigo/. This process is explained in the following screenshots:

https://leonardoce.files.wordpress.com/2011/12/wpid-flash_builder_jboss_1.png

https://leonardoce.files.wordpress.com/2011/12/wpid-flash_builder_jboss_2.png

https://leonardoce.files.wordpress.com/2011/12/wpid-flash_builder_jboss_3.png

Now you can choose the “Indigo” site to get the package list populated. You must install Eclipse Java EE Developer Tools and Eclipse Web Developer Tools.

Then you can follow the same procedure using the JBoss Tools update site, http://download.jboss.org/jbosstools/updates/development/indigo/. When you are done you must disable the update sites you have added because if you install any updates from the Indigo update site Flash Builder will stop working. Updating base Eclipse in a Flash Builder installation is not supported. See bug FB-30479 and bug FB-31761.

To disable the update sites you can open the “Available Software Sites” preferences and, in the next window, remove the repositories you just added.

https://leonardoce.files.wordpress.com/2011/12/wpid-flash_builder_jboss_4.png

Please keep in mind that you can’t update the base Eclipse of a Flash Builder installation!

Flash Builder and JBoss Tools 3.3

Air 2.7 and Menu Softkey on Android Honeycomb

If you are developing using Air 2.6 you are probably using the menu softkey to make users navigating the application.

https://leonardoce.files.wordpress.com/2011/12/wpid-menu_softkey_on_android.png

When you will upgrade to Flash Builder 4.6 the menu key will disappear!

In effect, as the bug report 2936827 reported against Air 2.7 explains, Air 2.7 is targeting, by default, Android SDK 11. This makes your menu key disappearing.

I think you, and our, must try to not use the menu softkey but, in the mean time, you can re-enable the menu soft key setting up the targetSdkVersion in your AIR application descriptor:

<android>
        <manifestAdditions><![CDATA[
                        <manifest android:installLocation="auto">
                                <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="10"/>
                                [....]
                        </manifest>
                        [....]
                ]]>
        </manifestAdditions>
</android>
Air 2.7 and Menu Softkey on Android Honeycomb