ANDROID: Install apk on emulator

You can view a list of emulators via:
android list avd

Start the emulator with:
emulator -avd [emu name]

Place the apk into the android/tools directory, and install it with:
adb install [apk name].apk

Resubmit the previous command if you get this message:
* daemon not running. starting it now *
* daemon started successfully *
error: device offline

BASH: Running bash script from dos

Lets say you have something that ONLY runs in cygwin... ie. the Android NDK makefile

usually you'd call this with cygwin like so:
make APP=[app name]

instead, you could create a bash script (we'll call it _build) file that contains the following:
#!/bin/bash
make APP=$1 $2;

then call this bash script with the following:
bash _build [app name] [-B]

oh, to make sure this works, you'll have to set windows env. 'path' to include c:\cygwin\bin directory.

Android: adb shell

To manually kill a process that is running:

adb shell


In the shell, type:

ps


This will produce something like the following:

app_23 --- 19333 --- 19283 --- 840 --- 312 --- ffffffff --- com.sample.app


Kill the process with the PID:

kill 19333

Android: Dirty build JNI

*EDIT
actually the problem was the JNI shared libraries in eclipse were out of sync with the actual. To solve this issue, simply do a refresh on the entire tree.
*EDIT

I ran into a weird dirty-build bug. Where even after I rebuilt the JNI shared library, it wouldn't load my new library onto the phone.

To solve:

- delete the application from the handset (settings > applications > manage...)
- delete the bin directory
- while you're at it delete the gen directory
- close the project
- delete the project
- import the project as new

at this point you will probably see a very annoying error that states:

"gen directory is missing" fix missing paths before continuing...

- build the application
- if android glitches and doesn't remove the error messages, make sure gen/bin were created by the previous step
- close the project
- delete the project
- import the project as new (AGAIN)

this time the error message should be gone.

Regex: Eclipse Search & Replace

to convert #defines into java final vars...

#define DEFINE_VARIABLE 0x12AB

Search and replace:
#define -> public static final int
(0x[\dA-F]{4}) -> = \1;

Result:
public static final int DEFINE_VARIABLE = 0x12AB;