Wink Saville’s Blog

February 12, 2008

Eclipse - ant and build.xml

Filed under: Android, Ant, Eclipse, java — wink @ 1:31 pm

This week I converted async-msgcomp to use ant for building rather than the internal Eclipse builders because it was the only way I could figure out to get jar files automatically built. After some trial an error I came up with common-build.xml which are common tasks for all sub-project and resides at the root of my build tree. I also created android-build.xml which is in the android sub-directory and is the common Ant tasks for Android. Then within each sub-project is a build.xml, for instance java/debug/build.xml and android/debug/build.xml as well as a global build.xml file in my root. For full disclosure; common-build.xml was based on the build.xml file emitted by:

File -> Export -> General -> Ant Buildfiles

And android-build.xml is based on the build.xml file emitted by running:

android-sdk/tools/activityCreator.py

The build.xml files are then used by executing ant in the appropriate sub directory. By executing ant in the root all of the sub-projects are built. Eclipse is also capable of building using Ant but you have setup the properties for each sub-project, which I’ll try to outline below. Sometimes Eclipse has trouble and either won’t execute saying they are still errors or it won’t execute because the classpath isn’t set properly.

One solution that has helped is to delete all projects and re-import them. Two other important items is that the Run parameters must be setup properly in <Run/Open Run Dialog> must be set properly and Build parameters for must be good.

Anyway, here is an example of setting the project properties so that external Ant files are used for compiling, in the example below I’m setup the sub-project “debug”. We assume there is a build.xml file in the sub-project.

Project -> Properties -> Builders -> new:

Main.Name: = debug-build.xml
Main.Buildfile: = Browse Worksapce => debug/build.xml
Main.Base Directory: = Browse Workspace => debug
Targets.After a “Clean”: = <default target selected>
Targets.Manual Build: = <default target selected>
Targets.Auto Build: = <default target selected>
Targets.During a “Clean”: = clean

Project -> Properties -> Builders = select only debug-build.xml deselect all others
Project -> Propertiers -> java Build Path -> Libraries = Add appropriate Libraries
Project -> Propertiers -> java Build Path -> Order and Export = the Libraries
Project -> Propertiers -> Project References -> Project references for debug: = select appropriate projects

In the Project -> Properties -> Builders where we select only debug-build.xml and deselect all others includes the following if it is an Android sub-project:

Android Resource Manager
Android Pre Compiler
Java Builder
Android Package Builder

If it is “pure java” project than you just deselect Java Builder.

February 11, 2008

Android - Eclipse “Could not find xxxx.apk”

Filed under: Android, Eclipse — wink @ 10:45 am

Today started off poorly, I decided to create ews (eclipse workspace) directory and then put the workspaces in that sub-directory. I started with an empty workspace as I have my sources separate from the workspace and then added in debug. I was able to compile fine but when I tried to run the android application I got:

[2008-02-11 10:36:03 - mc-android] Android Launch!
[2008-02-11 10:36:03 - mc-android] Could not find /bin/mc-android.apk!

Of course there was an mc-android.apk but it’s not in “/bin” (off the root) its at “bin” relative to the sub-project. Anyway, the solution appears to be to remove the project and import it again.

January 29, 2008

Android - Emulator Console and multiple instances of emulator

Filed under: Android — wink @ 10:58 am

My previous post on the tip for redirecting UDP had another tidbit that Digit eluded to and that is using the telnet to get to the Emulator Console. This page in the Android documentation give more information on the Console.

What is enlightening is that it state that upto 16 devices can be running at any time. Also, of note is that there is a possible security problem in that it listens on all networks, but that in the future it will only listen on localhost.

As for supporting multiple devices, see this section. To allow multiple instances to have their own “areas” you can the emulator with different options, these include -data, -ramdisk and -sdcard.

Android - Receiving UDP packets

Filed under: Android — wink @ 10:46 am

In this post by Digit shows how to use redirection to receive UDP packets on android.

1/ telnet localhost 5554 (i.e. go to the emulator control console)
2/ type “redir add udp:5000:9000″ (create a UDP redirection)
and now, any UDP incoming traffic on host UDP port 5000 will flow to guest
UDP port 9000
change the numbers to suit your needs. you can create TCP redirections as
well

“redir add help” will give you more information while in the control console

January 26, 2008

Android - how to make a local Service

Filed under: Android — wink @ 2:12 pm

In Android local Services my the convince that the thread the run in is the same thread as the thread that created them. To make a local service you change the AndroidManifest.xml <service /> tag so that the process attribute is absent.

So for my TestMc code I changed the manifest <service /> tag from this:

 <service class=”.TestMcService” android:process=”:remote” />

To:

 <service class=”.TestMcService” />

January 24, 2008

Android - Jan 23 cocoa & s’mores around the fake Campfires

Filed under: Android — wink @ 11:48 am

Last night I attended the Android get together at Google in Mountain View. It was nice to put faces to the people we see on the mailing list. The first hour plus was devoted to Q&A with most of the questions revolved around platform/business questions. Many of the developers, including myself, are worried that the platform will be castrated and fragmented in the way J2ME has been.

As the story goes the developers see platforms (J2ME, Windows Mobile, Symbian) with many types of capabilities but when the reach consumers many things have been removed. The prime example given was SMS; carriers charge per message so when the smart phones come out support other types of messaging isn’t supported. Another example might be ringtones or support for Skype, I’m sure the list could go on and on.

Anyway, the jist of the first hour was that the developers hope that Google will be able to “guarantee” a common set of capabilities that all phones will have. But since the platform is open source and Apache licensed anybody can do whatever they want. The only enforceable approach would be on the branding side. If you want the “Android” brand they you will support these features. I think we all hope the right thing happens.

After the Q&A session everyone huddled in groups around the varous Google people, this included Dan Morrill, Dianne Hackborn, Jason Chen and others whom I didn’t catch there names. In these groups more technical discussions ensued, for myself I talked with Dianne about async-messaging, serialization and networking. No revelations, but it was a good conversation. I was talked with Dan and a couple of developers about wifi and impressed upon them the need to allow peer to peer communication over wifi and allowing applications to source data for the media renderer’s.

I also, gave my business card to various people at Google, I’d like to work more closely with them either as a consultant or possibly an employee, we’ll see. If nothing happens soon on that front then I’m going to have to be look’n for something real soon now to put food on the table.

Cheers,

Wink Saville

January 18, 2008

Android - Bug: Thread hangs writing to outer class variable

Filed under: Android, programming — wink @ 12:07 pm

Below is an bug I reported to android-developers and android-bug, it is quite strange, while executing an assignment statement the code just hangs. No errors, exceptions nothing.

Hello,

A possible bug that seems to be associated with accessing
variables of an outer class from an inner class that is a Runnable.
Maybe its a bug in my code, but I don’t see it and if it is
I wouldn’t have expected Java code to just hang on an
“assignment” statement.

In this file:
http://async-msgcomp.googlecode.com/svn/trunk/android/mc/src/com/saville/android/mc/McMgr.java
If lines 216 or 218 are commented out:

214             /** ******************************************************************************** */
215             /* FIXME: Next statement required to see “… run() 2″ below */
216             mSecondaryPort.get();
217             /* FIXME: Next statement required to see “… run() 3″ below */
218             mServerRunning = 0;
219             /** ******************************************************************************** */

Then the Thread started will stop execution with no error at line 241 or 244:

238             /** ******************************************************************************** */
239             Log.v(df, “%s: McServer; run() 1″, mName);
240             /* FIXME: We’ll die if mSecondary.get() isn’t in McServer() */
241             mSecondaryPort.set(mPort + 1);
242             Log.v(df, “%s: McServer; run() 2″, mName);
243             /* FIXME: We’ll die if mServerRunnging=0 isn’t in McServer() */
244             mServerRunning = 1;
245             Log.v(df, “%s: McServer; run() 3″, mName);
246             /** ******************************************************************************** */

The entire code base is from Revision 13 of this repository for http://async-msgcomp.googlecode.com
There are several applicatons in this repository the one in question is “android/mc”.
I tried to make a simpler test but as would be expected it didn’t fail.

I’m running m37a on Linux:

wink@ic2d1:$ uname -a
Linux ic2d1 2.6.22-14-generic #1 SMP Tue Dec 18 05:28:27 UTC 2007 x86_64 GNU/Linux

Feel free to contact me  <first name>@<last name>.com if any
additional information is needed.

Regards,

Wink Saville

January 17, 2008

Connecting two Androids via TCP

Filed under: Android, linux, qemu — wink @ 4:02 pm

Below is an email which I sent to android-developers concerning how to  get two Androids talking to each other. This isn’t the solution, but is a path that might lead to a solution:

Hello,

I and it seems others would like to connect two Androids via TCP a previous
attempt failed with a segfault in the emulator. Digit and Alexey helped
resolve that, thanks.

I thought I’d report my progress and hopefully enlist some more
help. As I sad, my goal is to connect two Androids via TCP my path to a solution
is to allow the emulator(s) to appear on my local network by using a
bridge running in the host and having the qemu/Android use TUN/TAP
to connect to the bridge. This comes from http://compsoc.dur.ac.uk/~djw/qemu.html.

At the moment I have made some progress, I successfully bridged the
Android to my host as well as to the internet and was able to ping from
the Android console to my host and visa-versa. I also, was able to ping
an address on the internet, so progress was made.

Here is what I’ve done to get this far: (Note; this was done on Linux box, uname -a:
Linux ic2d1 2.6.22-14-generic #1 SMP Tue Dec 18 05:28:27 UTC 2007 x86_64 GNU/Linux)
This first series of steps only a single nic is needed, the second series I
tried using two nics.

1) Setup a bridge on my host.
a) Install bridge-utils
b) Besure TUN/TAP is configured in the kernel, the following
should print CONFIG_TUN=m or CONFIG_TUN=y
grep CONFIG_TUN= /boot/config-`uname -r`
c) You also need /dev/net/tun if it doesn’t exist then:
sudo mknod /dev/net/tun c 10 200
d) Create and initialize the bridge to your host ethernet
I created a script, br0, which creates the bridge,
attaches eth0, and then uses dhcp to get an address:

#!/bin/sh
set -x
# remove br0 if it exists
ifconfig br0 down
brctl delbr br0
# remove ip address from eth0
ifconfig eth0 0.0.0.0
# create a bridge
brctl addbr br0
# add eth0 to the bridge
brctl addif br0 eth0
# get br0 an address via dhcp
dhclient3 br0

Running br0 produces the following on my system:

wink@ic2d1:$ sudo ./br0
+ ifconfig br0 down
+ brctl delbr br0
+ ifconfig eth0 0.0.0.0
+ brctl addbr br0
+ brctl addif br0 eth0
+ dhclient3 br0
There is already a pid file /var/run/dhclient.pid with pid 13709
killed old client process, removed PID file
Internet Systems Consortium DHCP Client V3.0.5
Copyright 2004-2006 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/

wmaster0: unknown hardware address type 801
wmaster0: unknown hardware address type 801
Listening on LPF/br0/00:17:31:e1:ce:a3
Sending on   LPF/br0/00:17:31:e1:ce:a3
Sending on   Socket/fallback
DHCPREQUEST on br0 to 255.255.255.255 port 67
DHCPREQUEST on br0 to 255.255.255.255 port 67
DHCPDISCOVER on br0 to 255.255.255.255 port 67 interval 8
DHCPOFFER from 192.168.0.2
DHCPREQUEST on br0 to 255.255.255.255 port 67
DHCPACK from 192.168.0.2
/etc/dhcp3/dhclient-exit-hooks.d/sendmail: line 28: /usr/share/sendmail/dynamic: No such file or directory
/etc/dhcp3/dhclient-exit-hooks.d/sendmail: line 31: update_interface: command not found
/etc/dhcp3/dhclient-exit-hooks.d/sendmail: line 40: update_host: command not found
/etc/dhcp3/dhclient-exit-hooks.d/sendmail: line 46: update_sendmail: command not found
bound to 192.168.0.133 — renewal in 36889 seconds.

Using brctl and ifconfig to show the configuration

wink@ic2d1:$ brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.001731e1cea3       no              eth0

wink@ic2d1:$ ifconfig
br0       Link encap:Ethernet  HWaddr 00:17:31:E1:CE:A3          inet addr:192.168.0.133  Bcast:192.168.0.255  Mask:255.255.255.0
inet6 addr: fe80::217:31ff:fee1:cea3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:121 errors:0 dropped:0 overruns:0 frame:0
TX packets:120 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:35187 (34.3 KB)  TX bytes:15917 (15.5 KB)

eth0      Link encap:Ethernet  HWaddr 00:17:31:E1:CE:A3          inet6 addr: fe80::217:31ff:fee1:cea3/64 Scope:Link
UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
RX packets:10125 errors:0 dropped:0 overruns:0 frame:0
TX packets:7850 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5589385 (5.3 MB)  TX bytes:842531 (822.7 KB)
Interrupt:19

And I can still ping, so my host is OK:

wink@ic2d1:$ ping google.com
PING google.com (72.14.207.99) 56(84) bytes of data.
64 bytes from eh-in-f99.google.com (72.14.207.99): icmp_seq=2 ttl=241 time=86.9 ms
64 bytes from eh-in-f99.google.com (72.14.207.99): icmp_seq=4 ttl=241 time=92.8 ms
64 bytes from eh-in-f99.google.com (72.14.207.99): icmp_seq=5 ttl=241 time=89.4 ms
64 bytes from eh-in-f99.google.com (72.14.207.99): icmp_seq=6 ttl=241 time=96.6 ms
64 bytes from eh-in-f99.google.com (72.14.207.99): icmp_seq=7 ttl=241 time=97.8 ms

— google.com ping statistics —
8 packets transmitted, 5 received, 37% packet loss, time 7016ms
rtt min/avg/max/mdev = 86.995/92.746/97.814/4.125 ms

2) Qemu needs to connect to the TUN/TAP and it uses a
script, which by default is /etc/qemu-ifup. For these tests
I ran as root (sudo -s) as permissions are correct
but thats a problem for later

Here is /etc/qemu-ifup:

#!/bin/sh
echo Executing /etc/qemu-ifup
echo Bringing up $1 for bridged mode…
sudo /sbin/ifconfig $1 0.0.0.0 promisc up
echo Adding $1 to br0…
sudo /usr/sbin/brctl addif br0 $1
echo Sleep a couple of secs
sleep 2
echo Complete /et/qemu-ifup

3) Execute the emulator (as root), this is the simplest set of qemu parameters
I could find that allowed the Android onto the local network and out to
the internet. NOTE: with this configuration there is only one nic, eth0.
I understand I should use two nics, see second series, but this is initially
sufficient to do something useful although adb and dns don’t work
maybe because it’s not at the expected ports/addresses

On host (as root) execute the emulator with qemu parameters:

emulator -console -qemu -net user -net nic,vlan=0 -net tap,vlan=0,ifname=tap0

From emulator console see that there is only one smc device:

# /data/busybox/ls -ld /sys/devices/platform/smc*
drwxr-xr-x    3 0        0               0 Jan 17 21:45 /sys/devices/platform/smc91x.0
#

An interesting point is that adb is working at the moment, maybe
because tap0 isn’t being used(?)

wink@ic2d1:$ adb devices
List of devices attached
1       emulator-tcp-5555       device  0

wink@ic2d1:$ adb shell
# exit
wink@ic2d1:$

4) To connect to my host’s network I then executed the following
from the Android console prompt:

ifconfig eth0 down
ifconfig eth0 192.168.0.213 up
route add default gw 192.168.0.2 dev eth0

5) ping the gateway from Android:

# ping -c 1 192.168.0.2
PING 192.168.0.2 (192.168.0.2) 56(84) bytes of data.
64 bytes from 192.168.0.2: icmp_seq=1 ttl=64 time=13.4 ms

— 192.168.0.2 ping statistics —
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 13.400/13.400/13.400/0.000 ms

6) ping google.com (note dns doesn’t work so use address):

# ping -c 1 72.14.207.99
PING 72.14.207.99 (72.14.207.99) 56(84) bytes of data.
64 bytes from 72.14.207.99: icmp_seq=1 ttl=241 time=87.8 ms

— 72.14.207.99 ping statistics —
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 87.882/87.882/87.882/0.000 ms

7) From the host ping the Android:

wink@ic2d1:$ ping -c 1 192.168.0.213
PING 192.168.0.213 (192.168.0.213) 56(84) bytes of data.
64 bytes from 192.168.0.213: icmp_seq=1 ttl=64 time=0.532 ms

— 192.168.0.213 ping statistics —
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.532/0.532/0.532/0.000 ms

8) Finally, although adb can see the emulator the shell hangs

wink@ic2d1:$ adb devices
List of devices attached
1       emulator-tcp-5555       device  0

wink@ic2d1:$ adb shell
<- Used CTRL-C to break out
wink@ic2d1:$

============================
Second series trying to use two nics but can’t
get packets though to the host, I’m doing
something wrong!
============================

1) Now we’ll execute with two nic’s

emulator -console -qemu -net user -net nic -net nic,vlan=1 -net tap,vlan=1,ifname=tap0

2) Verify there are two smc devices:

# /data/busybox/ls -ld /sys/devices/platform/smc*
drwxr-xr-x    3 0        0               0 Jan 17 21:45 /sys/devices/platform/smc91x.0
drwxr-xr-x    3 0        0               0 Jan 17 21:45 /sys/devices/platform/smc91x.1
#

3) Bring up eth1 and ping it

# ifconfig eth1 192.168.0.213 up
# netcfg
gre0     DOWN  0.0.0.0         0.0.0.0         0×00000080
tunl0    DOWN  0.0.0.0         0.0.0.0         0×00000080
eth1     UP    192.168.0.213   255.255.255.0   0×00001043
eth0     UP    10.0.2.15       255.255.255.0   0×00001043
lo       UP    127.0.0.1       255.0.0.0       0×00000049
#
# ping -c 1 192.168.0.213
PING 192.168.0.213 (192.168.0.213) 56(84) bytes of data.
64 bytes from 192.168.0.213: icmp_seq=1 ttl=64 time=1.15 ms

— 192.168.0.213 ping statistics —
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.157/1.157/1.157/0.000 ms
#
# /dev/busybox/ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:57          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:7 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:790 (790.0 B)  TX bytes:0 (0.0 B)
Interrupt:13 DMA chan:ff

eth1      Link encap:Ethernet  HWaddr 52:54:00:12:34:56          inet addr:192.168.0.213  Bcast:192.168.0.255  Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
Interrupt:12 Base address:0×2000 DMA chan:ff

lo        Link encap:Local Loopback          inet addr:127.0.0.1  Mask:255.0.0.0
UP LOOPBACK RUNNING  MTU:16436  Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

But I can’t get packets routed though eth1 to host

# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.2.0        *               255.255.255.0   U     0      0        0 eth0
192.168.0.0     *               255.255.255.0   U     0      0        0 eth1
default         10.0.2.2        0.0.0.0         UG    0      0        0 eth0
# route del default
# route add default gw 192.168.0.2 dev eth1
# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.2.0        *               255.255.255.0   U     0      0        0 eth0
192.168.0.0     *               255.255.255.0   U     0      0        0 eth1
default         192.168.0.2     0.0.0.0         UG    0      0        0 eth1
# ping -c 1 192.168.0.213
PING 192.168.0.213 (192.168.0.213): 56 data bytes
64 bytes from 192.168.0.213: seq=0 ttl=64 time=3.281 ms

— 192.168.0.213 ping statistics —
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 3.281/3.281/3.281 ms
# ping -c 1 192.168.0.2
PING 192.168.0.2 (192.168.0.2): 56 data bytes

— 192.168.0.2 ping statistics —
1 packets transmitted, 0 packets received, 100% packet loss

I’m guessing the problem might have to do that tap0 seems
to be connected to eth0 not eth1 as mac connected to the
bridge seems to be from eth0. Doing the following after
running the 2 nic configuration:

# export PATH=/data/busybox:$PATH
# ifconfig eth1 192.168.0.213 netmask 255.255.255.0 up
# route del default
# route add default 192.168.0.2 dev eth1
# ping -c 1 192.168.0.213

Then on the host,  look at the macs connected to the bridge:

wink@ic2d1:$ brctl showmacs br0
port no mac addr                is local?       ageing timer
1     00:16:b6:81:90:ce       no                 2.29
1     00:17:31:e1:ce:a3       yes                0.00
2     00:ff:45:7f:1d:62       yes                0.00
2     52:54:00:12:34:57       no                 0.06

We see from the ifconfig the mac addr (52:53:00:12:34:57) is from eth0
I would have expected we want it from eth1(52:54:00:12:34:56). It’s
also interesting that eth0 has mac addr :57 which is what I’d expect
eth1 to have. When running the emulator with no parameters the
mac addr for eth0 is :56.

# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:57          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:36 errors:0 dropped:0 overruns:0 frame:0
TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:9762 (9.5 KiB)  TX bytes:630 (630.0 B)
Interrupt:13 DMA chan:ff

eth1      Link encap:Ethernet  HWaddr 52:54:00:12:34:56          inet addr:192.168.0.213  Bcast:192.168.0.255  Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:5 errors:0 dropped:0 overruns:0 frame:0
TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:320 (320.0 B)  TX bytes:126 (126.0 B)
Interrupt:12 Base address:0×2000 DMA chan:ff

lo        Link encap:Local Loopback          inet addr:127.0.0.1  Mask:255.0.0.0
UP LOOPBACK RUNNING  MTU:16436  Metric:1
RX packets:7 errors:0 dropped:0 overruns:0 frame:0
TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:544 (544.0 B)  TX bytes:544 (544.0 B)

============================

Anyway, if you got to here thanks all the more:)
If you have any suggestions they would be appreciated.

Wink Saville

January 14, 2008

Android - peer to peer TCP connections not possible?

Filed under: Android — wink @ 7:47 pm

I gave it the old college try, but it doesn’t appear to direct peer to peer communication is possible in the Emulator. I rediscovered a bug originally reported here where the Emulator segfaults when trying to configure qemu to use a vlan.

I also posted, what I think is a related question regarding, how to get Android ping the host computer here, maybe, some one will come up with a solution.

December 23, 2007

Android - use dx to disassemble

Filed under: Android, programming — wink @ 6:45 pm

To disassemble an entire  jar file as a disassembled dex use the following:

dx –dex –dump-to=abc –locals=full –positions=lines com.saville.android.debug.jar

Click here to see the output.

Here is an example of using dx, the android jvm-byte-code to dex converter to disassemble a method in a class. The input is a “.jar” file of my debug class and I’m dumping the print method of class Log:

wink@ic2d1:$ dx –dex –dump-method=com.saville.android.debug.Log.print com.saville.android.debug.jar
com/saville/android/debug/Log.print:(Ljava/lang/String;[Ljava/lang/Object;)V:
0000: move-object v0, v6
0001: move-object v1, v7
0002: const/4 v2, #int 4 // #4
0003: const-string v3, “” // string@0000
0005: move-object v4, v0
0006: move-object v5, v1
0007: invoke-static {v4, v5}, java/lang/String.format:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String; // method@0014
000a: move-result-object v4
000b: invoke-static {v2, v3, v4}, android/util/Log.println:(ILjava/lang/String;Ljava/lang/String;)I // method@0000
000e: move-result v2
000f: return-void
source positions
0000: 56
000f: 57
source file: Log.java

Newer Posts »

Powered by WordPress