Wink Saville’s Blog

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 28, 2008

git - getting git-svn to work

Filed under: scm — wink @ 3:34 pm

I’ve been working with the async-msgcomp svn repository by creating a single working directory with both .git and .svn directories. I then setup each to ignore the others files as well as some files Eclipse uses that should be in the scm. My .git/info/exclude file contains:

 bin
.metadata
R.java
.svn

My [miscellany] section of ~/.subversion/config [miscellany] contains:

 global-ignores = .git bin R.java *.class .metadata *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store

This was fine but did make things laborious as I had to checkin twice, one for each and maintaining the commit comments was painful. At first I figured I do several git checkins then a svn checkin, but it turns out 1:1 seems to work fairly well.

But there is a better way, git-svn, I did find a quick cheat sheet here with the following a suggested work-flow:

git svn clone -s <svn_repo>
git checkout -b <work_branch>

...hack...hack...

git commit -a
git checkout master
git svn rebase
git merge <work_branch>  #NOTE: no need for --squash anymore
git svn dcommit -e  # -e will let you enter a commit message for SVN

When I first tried the first statement (git svn clone <svn_repo> failed with:

 Can't locate SVN/Core.pm in @INC

Searching the Net it turns out I needed to install libsvn-perl via apt/synaptic, after doing so I could clone the async-msgcomp repo using:

git svn clone -s  https://async-msgcomp.googlecode.com/svn --username wink@saville.com async-msgcomp

This looks like a pretty good introduction to git-svn, the only problem is that its for pre 1.5.3.4 and includes the need for a –squash on the merge.

After cloning the svn repo, I also want a backup git repo on my server. Turns out that just following my instructions for setting a remote git repo worked perfectly (actually, doing this led me to find how to use the “git add remote”.

I have run into one problem, if the my git server repo gets out of sync with the svn repo I’m in trouble. The symptom of the trouble is an attempt to push the local repo to the server gets refused because its not a fast forward. This happens if I push to the server before doing the git svn dcommit. The git svn dcommit command places another commit on the local and hence if I’ve all ready pushed before the dcommit it won’t push.

The quickest solution is to remove the current remote, recreate an empty repo on the server as before and push it out again. Alternatively is start all over with a new git svn clone.

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.

Eclipse - settings and moving workspaces

Filed under: Eclipse, programming — wink @ 11:08 am

I checkout ws-msgcomp onto my laptop and wanted to move the settings from my main machine to the laptop. I found that Eclipse really doesn’t like to do that and when you do things still need tweaking.

Here was a link on what someone did for moving the settings so I created a tar script to save the settings:

tar -cjvf $1.tbz .metadata/.plugins/org.eclipse.core.runtime .metadata/.plugins/org.eclipse.ui.workbench

I saved this as backup-eclipse-settings.sh in my local bin file and executed:

backup-eclipse-setting.sh settings

creating settings.tbz I scp that to the laptop and untared it. then executed eclipse. First problem was I had my old files but no projects were imported. I imported the projects but they wouldn’t compile because “aapt” couldn’t be found even though it was there in the path it said it expected it to be. Turns out I needed to reset the android SDK path; In the Eclipse menu “Windows -> Preferences -> Android -> SDK Location:” I used Browse to reset it, even though it was correct.

Next I had to goto each of the projects and “Browse” to each of the imported libraries by selecting the Project then using the Eclipse menu; “Project -> Properties -> Java Build Path -> Libraries” and then select each of the jar’s Editing the location browsing to the actual location.

So it seems that even though the textual path is the same that isn’t enough, its almost seems it keeps the inode. Bottom line Eclipse doen’t handle paths well.

January 5, 2008

Eclipse - line wrapping and indentation when formatting

Filed under: Eclipse, java — wink @ 11:45 am

Eclipse is a reasonable IDE and it has a reasonable pretty printer (Source/Format or Shift+Ctrl+F) except for one thing; when a function call exceeds 80 characters the formatting is terrible in my opinion:

/**
* Arguments
*/
class Example {
  void foo() {
    Other
             .bar(
                     100, 200, 300,
                     400, 500, 600,
                     700, 800, 900);
    }
}

Anyway, this can be changed by going to menu:

Window/Preferences/Java/Code Style/Formatter

Here you should make a “New” profile from an existing profile that is close to what you want, I used “Eclipse [built-in]” for my base, it was the default. And then select “Edit”. In the dialog box “Profile ‘….’” select “Line Wrapping” tab and then I changed “Maximum line width:” to 100 from 80 and then selected “Function Calls/Arguments” in the window below and then in the “Settings for agruments/Indentation policy:” selected “indent by one” this cured the formatting problem and now the above is:

/**
* Arguments
*/
class Example {
  void foo() {
    Other.bar(100, 200, 300, 400,
              500, 600, 700, 800, 900);
    }
}

Much better!

Newer Posts »

Powered by WordPress