Discuss IT and Design a variety of tutorials and design it. let's read that are useful to you. thank you for visiting my humble blog

The One-Stop Android SDK/Eclipse/ADT Installer You Always Wanted

one_stop_sdk
Getting started with Android development can be a little daunting to newcomers.  There are a few different downloads and configuration steps, and quite a few fail points, especially if handcuffed by a zealous IT security team.  Wouldn’t it be nice if you could download and install one package and be ready to rock right out of the gate?  Those iOS developers have it so easy!  Well, now you can too, with the handy dandyTreehouse Android Development Bundle!
“But I like configuring proxies and assembling eight different components I’ve never worked with before!”
Says no one.  Admittedly, the documentation for setting up your Android environment has improved greatly, but it’s still a time-consuming and confusing process for new Android developers.
Feel free to download and try out our bundles for Mac OS X or Windows.  Check out Stage 1 of Build an Android Crystal Ball App.  Specifically, go to the page for the video Android Setup and the Crystal Ball Project and select the bundle that corresponds to your operating system from the Download links below the video.  Unzip the bundle, run the “initial_setup” script, and start coding!
If you want to set up a bundle for your own use or to share with students or a team, follow the instructions below.

How to Create Your Own Android Development Bundle

The goal here is to create a self-contained directory where all the components have relative paths to each other.  The main problem with using relative paths is that the relative path for the Android SDK in Eclipse breaks the AVD Manager. It won’t allow you to run existing AVDs or create new ones. Enter the “initial_setup” script! This little script should be run one time when the bundle is first unzipped.  It sets the Android SDK to an absolute path based on where the user unzips the package, and it also creates an initial AVD.
The key to the script is updating the Eclipse ADT Plugin preferences to use the absolute path of the Android SDK. This is accomplished with this line from the script below. Note that the path for the preferences file is relative to the workspace (and the workspace path is set as relative to the Eclipse installation).
echo com.android.ide.eclipse.adt.sdk=$sdk_path >> ./workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings/com.android.ide.eclipse.adt.prefs 

MAC INSTRUCTIONS

Here’s what the final unzipped directory structure will look like. This is what we’re building:
Mac OSX Android Development Bundle Structure
  1. Create the root directory (android_dev_environment)
  2. Copy the Android SDK in (android-sdk-macosx)
  3. Copy in eclipse:
    1. Start with a clean version of Eclipse
    2. Run Eclipse. When prompted for a workspace, enter “../../../../workspace” (this will create the workspace directory in our root).
    3. Install the ADT Plugin via the “Install new software” option in Eclipse (https://dl-ssl.google.com/android/eclipse/). Restart when done.
    4. Change the Android SDK path in Eclipse preferences to be relative: “../../../../android-sdk-macosx”
    5. Install at least Platform Tools and the latest platform using the SDK Manager.
  4. Create initial_setup:
    #!/bin/bash
    # Set the Android SDK path in Eclipse. Must be the absolute; a relative path
    # does not work with the AVD Manager.
    cd "$(dirname "$0")"
    sdk_path=`pwd`/android-sdk-macosx echo
    "Setting Android SDK path in Eclipse..."
    echo com.android.ide.eclipse.adt.sdk=$sdk_path >> ./workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings/com.android.ide.eclipse.adt.prefs
    echo "Android SDK path set."
    # Create a new AVD echo
    "Creating new AVD..."
    echo no | $sdk_path/tools/android create avd -n Android41 -t 1 --force
    echo "AVD created."
  5. Change permissions of initial_setup: chmod 754 initial_setup
  6. Zip up the directory!

WINDOWS INSTRUCTIONS

Here’s what the final unzipped directory structure will look like. This is what we’re building:
Windows Android Development Bundle Structure
  1. Create the root directory (android_dev_environment).
  2. Install JDK 6 at android_dev_environment\Java.  In the installer, we only need to install Development Tools and the Public JRE (not the Java DB or Source Code).
  3. Install/copy the Android SDK in (android-sdk-windows).
  4. Copy in eclipse:
    1. Start with a clean version of Eclipse
    2. Edit eclipse\eclipse.ini. Add the following lines above the -vmargs line:
      -vm
      ..\Java\jdk1.6.0_35\bin\javaw.exe (make sure the jdk path is correct!)
    3. Run Eclipse. When prompted for a workspace, enter “../workspace” (this will create the workspace directory in our root).
    4. Install the ADT Plugin via the “Install new software” option in Eclipse (https://dl-ssl.google.com/android/eclipse/).  Restart when done.
    5. Change the Android SDK path in Eclipse preferences to be relative: “..\android-sdk-windows”
    6. Install at least Platform Tools and the latest platform using the SDK Manager.
  5. Create initial_setup.bat:
    REM Set the Android SDK path in Eclipse. Must be the absolute;
    REM  a relative path does not work with the AVD Manager.
    cd > temp.txt 2>&1
    set /p sdk_path= < temp.txt
    del temp.txt
    set sdk_path=%sdk_path%\android-sdk-windows
    set sdk_path=%sdk_path:\=\\%
    set sdk_path=%sdk_path::=\:%
    echo “Setting Android SDK path in Eclipse...”
    echo com.android.ide.eclipse.adt.sdk=%sdk_path%>> .\workspace\.metadata\.plugins\org.eclipse.core.runtime\.settings\com.android.ide.eclipse.adt.prefs
    echo “Android SDK path set.”
    REM Create a new AVD
    echo “Creating a new AVD...”
    echo no | .\android-sdk-windows\tools\android create avd -n Android41 -t 1 --force
    echo “AVD created.”
    pause
  6. Reset the eclipse.ini -vm path to a relative one (see Step 4B above). Apparently when you run Eclipse it updates this path to an absolute value.
  7. For 64 bit Windows, we also need to edit the find_java.bat file in the Android SDK so that it finds the Java installed with the bundle. Add the following lines to android-sdk-windows\tools\lib\find_java.bat (before it runs its own check that starts with the comment “rem Check we have a valid Java.exe…”):
    set java_exe=%~dp0\..\..\..\Java\jdk1.6.0_33\bin\java.exe
    set javaw_exe=%~dp0\..\..\..\Java\jdk1.6.0_33\bin\javaw.exe
    if defined javaw_exe goto :EOF
  8. Zip up the directory!
Note: Running the initial_setup script on a Mac or a PC multiple times does not hurt anything. The dev environment will break if you move the whole directory after running initial_setup, but running initial_setup from the new location will fix it. It might help to include a README file with the bundle explaining this and any other tips or troubleshooting advice you want to share.
Anybody have any similar solutions for Linux or another IDE like IntelliJ?  If so, leave a note in the comments!  :)

Share:

No comments:

Post a Comment

Popular Posts

Ismail Maha Putra. Powered by Blogger.
twitterfacebookgoogle pluslinkedinrss feedemail
SEO Reports for kendariit.blogspot.com

Followers

Blog Archive

Poll

Facebook Page Like

Translate

Get ThisWidget
Blogger Widgets

submit your site

http://smallseotools.com/google-pagerank-checker

Sonicrun

Google Search

Popular Posts

Tutorials, IT and Design

Blog Archive

Recent Posts

About Metro