Eclipse Indigo for Android Development on Mac OS X Snow Leopard

Mac OS X 1 Comment

eclipseI decided to install the latest version of Eclipse, Indigo, and configure it to do Android application development. My specific final target is to build the VLC Player for Android. Below are my notes for installing such an Eclipse configuration for Android development on a clean Mac OS X Snow Leopard system.

Note: These instructions also work for the latest Eclipse Juno version. Just replace references to Indigo with Juno.

Install Android SDK

  1. Download latest Android SDK (I downloaded “android-sdk_r12-mac_x86.zip”).
  2. Unzip and move the extracted “android-sdk-mac_x86” directory to “/Applications”, so you end up with “/Applications/android-sdk-mac_x86”.
  3. Add the following to the end of your bash environment configuration file “~/.profile”. (The tilde symbol ~ translates into your home directory “/Users/your_username”.)
    export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
    export ANDROID_SDK=/Applications/android-sdk-mac_x86
    export PATH=$PATH:$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools
    export NO_NEON=1

    Some details on the above:

    • Mac OS X Snow Leopard comes with the 64bit version of Java 1.6 installed by default. We are just setting the JAVA_HOME to point at it.
    • The PATH is optional but will make it easy for you to run the Android SDK Manager by typing “android” or the Android Debug Bridge by typing “adb” in the Terminal.
    • Set NO_NEON to prevent Android compilation from using the Neon CPU enhancements which are not supported on all Android devices (including the Emulator).
  4. Run the Android SDK Manager, by launching $ANDROID_SDK/tools/android, to install support for one or more Android OS platform versions. (It is mandatory that you install at least one OS platform version.)
    • Click on “Installed packages” to see what is installed by default, usually just the Android SDK Tool and Platform-tools.
    • Click on “Available packages”, expand “Android Repository”, and select the SDK Platform OS version that you want to develop for. For example, if you wish to do Honeycomb development (or your Android phone has Honeycomb), you can check “SDK Platform Android 3.0, API 11, revision 3”. You might wish to also get the samples by checking “Samples for SDK API 11, revision 1”.

    Optionally, while we have the Android SDK Manager opened, you can create an emulator by clicking on “Virtual devices”:

    • Click the “New…” button, name your emulator, select a platform OS version for the target, input a SD Card size like 32 or more, and hit the “Create AVD” button. The SD Card size is optional but some programs may fail to run if a SD Card is not present.
  5. Periodically, to update your installation, you may wish to go to “Installed packages” and click the “Update All…” button. This will return all updates (even for items not installed) which are applicable; you will need to select Reject for those items which you don’t want to install/update.

Install Android NDK

We will need the Android Native Development Kit (NDK) in order to compile the Android VLC JNI library:

  1. Download the latest Android NDK (I downloaded “android-ndk-r6-darwin-x86.tar.bz2”).
  2. Unzip and move the extracted “android-ndk-r6” directory to “/Applications”, so you end up with “/Applications/android-ndk-r6”.
  3. Edit “~/.profile” to add the following:
    export ANDROID_NDK=/Applications/android-ndk-r5b
    export PATH=$PATH:$ANDROID_NDK:$ANDROID_NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin

    The PATH is optional but will make it easy for you to run “ndk-build” from a Terminal. Also, when compiling projects like VLC, the android prebuilt tool will be required to be in the path.

Install Eclipse

  1. Download the latest Eclipse.
    • Select “Mac OS X (Cocoa)” in the “Packages for” drop-down listbox at the top to filter for only Mac versions.
    • Find the Eclipse flavor you want. If you aren’t sure, I recommend getting “Eclipse IDE for Java Developers”. Click on the “Mac OS X 64 Bit” to the right to download. (I downloaded “eclipse-java-indigo-macosx-cocoa-x86_64.tar.gz”.)
  2. Unzip and copy the extracted “eclipse” directory to “/Applications”, so you will end up with “/Applications/eclipse”.
  3. Start Eclipse and select your workspace location. (If you select an old location which was used by an older version of Eclipse, make sure to delete the “.metadata” sub-directory there first; otherwise, your new Eclipse will display old plug-ins and IDE modes which it may not have installed.)

Change How Eclipse Handles Search Results

In the recent versions of Eclipse, the default behavior for search is to reuse the editor. This default behavior can be annoying because it prevents you from being able to simultaneously view more than one search result. Opening a new search result would reuse the editor tab and cause the previous search result to become unavailable. To configure Eclipse to open each search result in a new editor tab, do the following:

  1. Go to menu “Eclipse->Preferences->General->Search”.
  2. Uncheck the “Reuse editors to show matches” option.

Install Android Eclipse Plugin (ADT)

Add the ADT to Eclipse:

  1. Run Eclipse.
  2. Select Help->Install New Software…
  3. Input “https://dl-ssl.google.com/android/eclipse/” into the “Work with:” field. Hit Enter. The table below should populate automatically. (You can use the optional Add button if you want to bookmark this URL.)
  4. In the table, expand “Developer Tools” to see what it contains.
  5. Check the “Developer Tools” box to select all. (If you want just the minimum, check only “Android Development Tools”.)
  6. Click Next, Next, select “I accept the terms of the license agreements” radio button, and click Finish.
  7. If the Security Warning dialog about the “unsigned content” appears, click Ok to accept.
  8. Click on “Restart Now” to restart Eclipse.

Configure the ADT:

  1. Under Eclipse, go to menu Eclipse->Preferences.
  2. Select Android.
  3. In the “SDK Location”, browse to your android install directory (directory pointed at by $ANDROID_SDK or “/Applications/android-sdk-mac_x86”).
  4. Hit Apply and you should see the Android platform versions you installed earlier populate the table.
  5. Hit Ok to close the dialog.

Install Eclipse IDEs for PHP and Javascript

Optionally, add the Javascript Development Tool (JDT):

  1. Go to Eclipse menu Help->Install New Software…
  2. Click on the dropdown arrow for the “Work with:” box and select “Indigo – http://download.eclipse.org/releases/indigo”. (If you don’t see this entry, just type in the URL manually.) The table will populate with a bunch of Indigo-compatible plugins.
  3. Type “javascript” into the “type filter text” field to show only the Javascript related plugins.
  4. Check the “JavaScript Development Tools” (for example, under “Programming Languages”) and click Next, Next, accept the license, Finish.
  5. Click on “Restart Now” to restart Eclipse.

Optionally, add the PHP Development Tool (PDT) by repeating the steps above, filtering on “PHP” instead, and selecting “PHP Development Tools” for installation.

Install Subversion Eclipse Plugin (Subclipse) and Compile Android VLC Player

If interested, see the next post for instructions on installing the Subversion Eclipse Plugin (Subclipse) and compiling the VLC Player for Android.

1 Comment

One Router to Rule Them All

Internet No Comments

applewirelessiconI recently bought an iMac for my sister. While setting it up, the Software Update would keep aborting due to network disconnects. While testing, I noticed my wireless G connection would start off fast, then drastically slow down, then pause for a minute, disconnect/reconnect, and finally just unable to connect. If I reboot, the behavior repeats. Strangely, my Macbook Pro and a Windows 7 desktop sitting nearby had no issues.

After hours of googling and trying out different suggestions, I came to the realization that the Apple wireless function is just very fickle. Wireless issues were attributed to the wireless hardware card, the firmware on the card, the Mac OS X version, the wireless driver, the Airport software version, the distance to the router, the type and model of the router, the type of connection (A, B, G or N), wireless channel used (1 thru 11), the encryption (no security, WEP, WPA, WPA2), and interference from Apple’s own bluetooth mouse/keyboard (if you use channel 6), wireless phones, walls, aquarium pump, neighbor’s routers, the metal kettle sitting on the stove, etc.

If you’re lucky and your Apple computer doesn’t have any issues with wireless, count your stars and if you are not, just pray that Apple will come out with a software fix soon. Or you can buy a wireless USB adapter (many have solved their wireless issues using this solution), but something sticking out of the back of the iMac defeats the reason to get an iMac (design cleanliness).

CNet’s MacFixIt Tutorial: Fixing Wireless connectivity is one of the better references I found. In addition to the tutorial suggestions, if you have an older router like a Wireless G router, I recommend disabling the IPv6 support as this might cause problems for your router and wireless connection. To disable IPv6 support, go to System Preferences->Network->Airport, click on the “Advanced…” button on the bottom right, select TCP/IP tab, change “Configure IPv6” to Off.

As a final test, I deployed a Wireless N router twice the distance away as my Wireless G router. The iMac connected to the Wireless N router and my wireless became 95% stable. There were still occasional drops but I could now watch Youtube videos at 360p. Strangely, I ran some wireless monitoring software (recommendations below) and the Wireless N signal was twice as bad as the Wireless G signal. Oh well, looks like this iMac puppy prefers Wireless N. Go figure.

During my investigation, I found some very cool and free (my second favorite word; my first is when you pay me) wireless monitoring software. Here are my recommendations:

  • If you are using Windows, get inSSIDer (better than NetStumbler!). I love inSSIDer’s graphical display that shows both signal strength and channel coverage (see below). You can see where the conflicts are and where the gaps are… so you can move your router channel there, assuming you’re lucky enough to have gaps.
  • If you are using Mac OS X, get iStumbler (NetStumbler for Mac?). It’s not as cool as inSSIDer, but it’s better than nothing.

Below is the inSSIDer graph for Wireless G from my Windows 7 desktop. My Wireless G router is in red and my temporary Wireless N router (supporting both G and N) is in yellow. I overwrote my SSIDs to protect my privacy while leaving the neighbors’ SSIDs visible (Muhuhaha… that’s evil laughter for the reading impaired). There is about 5-6 other wireless networks but they are so low power that they don’t show on the graph.

A month ago, it was just my nice neighbor, green 2WIRED732 (channel 8), and my Wireless G router (channel 11). Actually, my green neighbor is not too nice; he or she should be using channel 1 or 6, not 8. The recommendation is to keep 5 channels apart so in the 1-11 channel space, we should use 1, 6, and 11. Of course, this argument goes out the window when you have a lot of neighbors all over the channel spectrum.

Now, when I look at the graph, I see that my channel 11 space has been invaded by grey 2WIRE583… argh!!! And there is the evil blue belkin.3eb3 which is taking up both channels 3 and 7 (look at that wide channel coverage!). Between grey and evil blue, they have the whole 1 thru 11 channels covered! There is no gap.

That’s when an evil thought appear in my head. I need one router to rule over all other routers!

One Router to rule them all
One Router to find
One Router to bring me wireless
and in the congested emptyness to bind with!

I need the One Router that will cover the whole Wireless G and N channel spectrum (like my little friend, evil blue) and pump out 3-4 times the signal strength (need lotsa gigantic antenna and a backup generator). And maybe build an EM barrier around my house (time to stock up on aluminum foil?).

Yes, my precious! Yessss, my precioussss! Muhuhaha! (Again, that’s evil laughter for the… ah, never mind.)

No Comments

Transfer a Cassette Tape to an Audio CD

Audio Visual 1 Comment

cassettetapeI was asked for help to transfer a cassette tape to an audio CD. I found a great webpage, How to transfer a tape to a CD using Audacity, which provided most of the info. (Audacity is a free audio editing program.) The basic idea is to record from cassette tape to the computer and use the computer to burn an audio CD. Below are the steps I took:

Set the audio recording level and use Audacity to record from the cassette tape to the computer:

  1. Install Audacity. Because I am using Windows 7 64bit, I installed the recommended latest 1.3.13 Beta version.
  2. Connect the line-out jack on your cassette tape player (or headphone jack if there isn’t a line-out jack) to your computer’s line-in jack (or mic jack if there isn’t a line-in jack). (I will refer to line-in below; just substitute mic for line-in if you are using the mic input.)
    • Start playing the cassette tape.
    • You should hear the music from your computer speakers. If not, open up the computer speaker volume control (little speaker icon on the dock) and make sure that the line-in input is not muted.
  3. Adjust the audio input levels so that you don’t over-drive the speakers, basically play a sound louder than the maximum speaker volume. You can adjust the input levels using two controls: the volume on your cassette player and the line-in volume level control on the computer. There isn’t a single correct way of doing this; below are my recommended steps.
    • Set the line-in volume level on the computer to 50%. On Windows 7, right-click on the speaker icon in the dock, select Recording Devices, select “Line In”, click on Properties button, and adjust the drag bar to midway.
    • While watching the line-in volume level meter (in the same Recording Device “Line In” Properties dialog, you should see a volume meter that changes with the sound), adjust the cassette tape player volume so that the line-in volume level meter comes close to, but never reaches max.
    • If you feel the cassette tape player volume is too low (a perfect setting is one quarter up to one half), then adjust the line-in volume level down and the cassette player volume up. Or if you feel the cassette player volume is too high, then adjust the line-in volume level up and the cassette player volume down.
    • You don’t need to be perfect at this point because we will do an additional adjustment below.
  4. Double-check your sound levels by running Audacity, making sure that Stereo is selected in the Input Channels dropdown (in the middle of the bottom toolbar), and clicking on the Record button. Audacity will create a stereo track (with two bar graphs) to show the sound waveforms as they are recorded.
    • Look at the top-right of the Audacity window to see Audacity’s volume level meters for L (left) and R (right). You should see the levels changing as the sound plays. The “0” marker on the far right represents the maximum level.
    • Adjust the line-in volume level and cassette tape player’s volume so that the sound level comes close but never reaches the “0” marker.
    • It is better to be conservative and err on the side of not reaching the “0” marker, than exceeding it. (Exceeding it will saturated the recorded waveform, which is not a good thing.)
  5. Stop the Audacity recording and stop the cassette tape player. Rewind the tape to the beginning.
    • At this point, check to see whether your cassette tape is mono or stereo. If you look at Audacity and see two soundwave graphs (for left and right speakers) in the Audio Track, then it is stereo. If you see only one soundwave graph (the other is a blank grey box), then it is mono.
    • If it is mono, then select Mono in the Input Channels’ drop-down list which is in the middle of the bottom toolbar located above the Audio Track. The next time you record, a single mono Audio Track will be created (instead of a stereo track).
    • Delete the Audio Track by clicking on the X icon on the top-left of the Audio Track pane.
  6. We are ready to record from the cassette tape to the computer. Start playing the cassette tape. As soon as you can, hit Record in Audacity.
  7. Wait for the tape to finish playing and stop recording in Audacity. (Regular cassette tapes usually have 45 minutes recording on each side.) If your cassette tape player doesn’t automatically play side B after side A, then you can repeat these steps with side B separately.
  8. At this point, you can save the audacity project. The output will be a *.aud project file and a directory containing the recorded audio in WAV file format.

Use Audacity to clean the recording, mark the individual songs, and export each song as a WAV file:

  1. When recording from a cassette tape, there will be a hissing background noise which we want to get rid of. Also, we want to normalize the sound level.
    • Use Audacity to normalize the sound level by select the whole audio track (menu Edit->Select->All) and applying Normalize (menu Effect->Normalized). Accept the defaults in the Normalize dialog (“Remove any DC offset” and “Normalized maximum amplitude to: -0.0 db” selections are checked). The webpage I referenced above suggests normalizing to “-0.3 db” but that instruction doesn’t apply to the latest Audacity version which accepts “-0.0 db” as the maximum.
    • Use Audacity to remove the background hissing noise.
      1. Select a portion of the audio track which represents silence; either the space at the beginning, end, or between the songs. Then get a noise profile (menu Effect->Noise Removal… and click on the “Get Noise Profile” button” in Step 1) so Audacity will know what to remove from the whole track.
      2. Select the whole audio track (menu Edit->Select->All) and apply the Noise Removal (menu Effect->Noise Removal). In the Noise Removal dialog, take the defaults in Step 2 (Noise reduction dB should be 24 which is middle of the range, etc.) and hit OK. This operation may take a minute or two.
  2. Mark the breaks between songs so Audacity will recognize when a song begins and ends. (This will allow us to create an audio CD with multiple song tracks, allow skip forward/reverse, instead of an audio CD with one huge song track.) This is a manually instensive and time consuming task.
    • To make it easy to view the breaks between songs, set the zoom to normal (View->Zoom Normal) and maximize the Audacity window.
    • Starting from the beginning of the audio track, move the scrollbar at the bottom to the right by clicking on the right arrow (to move the viewable audio track by small increments) or by clicking on the empty space to the left of the right arrow (to view the audio track viewable chunk by viewable chunk).
    • Look for song breaks which occur when the soundwave graphs go to zero (you will see a single line). Click in the middle of the song break section and tag it as a new song track (menu Tracks->Add Label at Selection). You can name the label if you wish to.
    • You can double-check that it is actually a song break by clicking before the break and hitting play to listen to the end of the current song, the silent break, and the start of the next song.
    • Once you have looked at the whole audio track and are confident that you have identify the song breaks, export each song as a separate WAV file by going to menu “File->Export Multiple…”. Input an export location directory, make sure “Labels” is selected”, click on “Include audio before first label” if you didn’t put a tag before the first song, and click on the Export button.
    • Answer Yes if you are prompted to create the export location directory. You will be prompted to add more info for each song to be exported, just hit OK each time.
    • Once done, if you go to the export location directory, you should see a WAV file for each song.

At this point, use a CD burning software, such as Nero Burning ROM, to burn the individual song WAV files to an audio CD. An audio CD is 80 min long so if you are lucky, you might be able to fit the whole cassette (both sides A and B) onto one audio CD.

Good luck and have fun!

1 Comment