1

I am trying to enable assertions (the keyword, not the junit methods) in my android project.

What I've tried so far: I added a command line argument, -ea, in Eclipse (Indigo) under Eclipse > Preferences > Java > Installed JREs where I edit the only JRE listed (see two images below). List of installed JREs

Default VM Arguments

That didn't work... I assume because this applies to my default JVM, not the dalvik VM.

I found a related post that suggested running a command against the emulator or device (I am most interested in the emulator) to enable assertions. But I don't understand what that means. The command is:

adb shell setprop debug.assert 1 

So my question is, how do I run a command against the emulator (using a Mac, if that's relevant)?

Many thanks!

Community
  • 1
  • 1
Hap
  • 556
  • 1
  • 6
  • 20
  • @JohnGiotta Same as what? Maybe it would help if I framed this as a newbie question. When I hear "run command x against y", I simply don't know what that means. – Hap Dec 09 '11 at 21:49
  • I didn't realize you couldn't find where adb was located on your machine. No, I thought you expected the command to be different on a Mac... which it isn't, hence the question. – John Giotta Dec 10 '11 at 00:56

2 Answers2

2

So my question is, how do I run a command against the emulator

Open up a Terminal window (or your preferred equivalent, like iTerm), and type in the command at the command line. If you have not done so already, you need to add $ANDROID_SDK/platform-tools to your PATH, where $ANDROID_SDK is wherever you have unZIPped the SDK on your machine.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanks, @CommonsWare. I had to look up [how to add a directory to the PATH variable for mac](http://keito.me/tutorials/macosx_path) (that's how green I am). But after following your suggestions, I am able to get assertion errors! – Hap Dec 09 '11 at 22:15
0

First at all is necessary know the devices connected:

adb devices

And then select the desired device name and type:

adb -s <device-name> shell

At this point you are connected to the device shell and could execute commands.

Regards.

sabadow
  • 5,095
  • 3
  • 34
  • 51