Thursday, May 26, 2011

Setting up your Android/Java Environment: Lesson One

Happy Thursday everyone!
I've been getting LOTS of comments and questions on how to setup the runtime environment, so our first post is going to be about setting up the runtime environment. If you have any questions or problems, feel free to email me or leave a comment.
Next, because many people asked that we have a refresher on Java, I will be doing just that. For a few weeks, I will post some tutorials on Java; although I feel that Android development and Java are fairly different, knowing and remembering Java's structure is VERY beneficial. I will be following the book How to Think Like a Computer Scientist: JAVA Programming as I find that book very straightforward and helpful. If you would like to purchase the book, it's a good resource, but there is a free copy online: yhanks to Reddit user nydad for finding the free pdf of the book.
At the end of each Java lesson, I will post some sort of "challenge", as requested: some sort of problem for you to program on your own. If you would like to know how your solution did, feel free to email it to me (in the .java format; although runnable JARs would be more convenient, they make the server I use far more susceptible to loopholes and attacks, and therefore I won't open them).
With that, let's start up the setup procedure!

First off, there are many different IDEs you can use to develop with Java; however, since Eclipse and the Android Dev tools go so well together, we will be using Eclipse. Go ahead and download the Eclipse IDE for Java EE Developers from the link provided. Once downloaded, you will need to un-archive it (I'm on a Mac, I'm not sure about Windows), and simply place the folder in your Applications folder. To run, simply open the "Eclipse" icon in the "Eclipse" folder.
The first thing Eclipse will do is ask you for your workspace.
For me, I've simply picked my "Documents" folder, because I do a lot of work for school in Eclipse as well. You will be presented with a window with a few choices. In order to get started, choose "Workbench" in the top right corner.
You will then be presented with a window, which is where the main of your work will take place.

In order to get started in writing a Java app, you would choose "File -> New -> Project" and then select "Java Project", but that will be for this weekend. For today, we'll simply set up the Eclipse settings, and then setup and add the Android SDK as well.

Next, you will need the Java JDK downloaded. Currently, the Java JDK is on version 6, and can be found here. If you have version 5, you can use it as well; there's no need to update to version 6. Unless you really know about what to download, simply clicking "Next -> Next -> Finish" should suffice just fine.

Next, you will need the Android SDK found at the link provided. Simply unpack and install it to a directory you will remember, as you will need it when we start adding things to Eclipse.

Next, open Eclipse back up, as we will be adding the Android information to Eclipse. In Eclipse, select "Help -> Install New SOftware" as shown:
In the window that pops up, select "Add", and in the windows that pops up, enter "Android" for the name, and for the location, use "https://dl-ssl.google.com/android/eclipse/". Hit "OK". If that location does not work, take the "s" off of "https".

The following window will appear.

Please select all the packages that appear, and hit "Next -> Next", accept the terms, and then click "Finish". This will begin downloading the Android Development Tools. This will go on in the background of Eclipse. Once it's done downloading, it will prompt you to restart Eclipse. Please do so. (If it tells you you are downloading unsigned content, please say that it's okay.)


Next, please navigate to where you installed/placed the Android SDK. There should be a file named "SDK Setup.exe. Please run it. When opened, a window with the different types of Android packages should open. PLease select only the android packages which you would like to use (I usually pick 1.6, 2.1, 2.2, 2.3, and 3.0) Please "Accept" the terms and click "Install". This will take quite a bit of time to install all of these, so please be patient.


We're almost done!

Now that the ADT is done being installed, we need to create a virtual device. In the SDK manager, find "Virtual Devices", as we must make a device for you to test your software on!
In the name field, Name it something meaningful; probably the target name, so you remember which version of Android. Next, pick a target; essenially, whatever version of Android you want to tinker with. Leave the rest as is, and click "Create AVD". Once that is done, make sure you hit "Start" to make sure that it works. It will be a lengthy startup, but you should eventually get a Home screen for a typical Android phone.
Next, we need to configure Eclipse one more time. In Eclipse, go to Eclipse -> Preferences (or on Windows, Window -> Preferences) and pick the Android tab. Where it says SDK Location, please find the location where you put the Android SDK, and click "Apply".

Then click "OK".

And that's it! You have successfully configured Eclipse and the Android SDK together so that you can develop for Android. This weekend, we will be starting the tutorial on Java, to give you all a refresher.
If you have any issues with your setup, please leave a comment here, or email me at leonardoty@gmail.com. If you place it here or email it to me, I will do my best to troubleshoot your problem at get back to you. Alternatively, you can post it at

71 comments:

  1. Oh wow, I've been planning to get into Android development at some point over the summer, this blog may just well be perfect. Thanks!

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. To get the emulator working in Ubuntu, I had to follow this nice tutorial as well: http://blog.jayway.com/2009/10/21/getting-android-sdk-working-on-ubuntu-64/

    Looking forward to working on android.

    Cheers.

    ReplyDelete
  4. Do you have an RSS feed? I would love to subscribe in my news reader!

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. Quick Tip and a question:

    Quick Tip:
    For those of you that may have Eclipse already installed, but have it for C++ or PHP or something else, you can have Java on there as well without having to download and install a different version of Eclipse.

    (Im on a Mac, but it should basically be the same on Windows) Basically, you open your version of Eclipse (any workspace works), Help>Install New Software. Then in the "Work with:" dropdown bar, choose "Helios" (the most recent version, which you should already have).

    Now you get a couple of options in the window below. Expand the "Programming Languages" option by clicking on the little triangle arrow. Check the box for "Eclipse Java Development Tools" and install. Now when you open up Eclipse, you probably want to make a new workspace (I named mine "Java") to house your Java projects separate from your C++/or whatever language projects. When Eclipse finishes loading, you can simply switch to Java by going to Window>Open Perspective>Other... and select Java. You will notice that the top bar will change from C++ to Java and some of the GUI will also change. There you go!

    For more info: http://stackoverflow.com/questions/2642069/eclipse-is-it-possible-to-have-cdt-and-java-ide-together

    Question:
    I know we need the JDK v6. I originally went to Oracles site, but could not find a version for Mac. I did some research and I found that Mac OS X (what I have) already comes with the JDK installed. I tried opening a terminal and typing "java -version" and see that I have the Java SE Runtime Environment (build 1.6.0_24-b07-334-10M3326) and the Java HotSpot Client VM.

    I read somewhere that by running a software update from the apple menu you could get the latest JDK. However, since I dont see the JDK specifically mentioned on the terminal, I still dont know if I have the JDK already.

    Does Java SE (Standard Edition) already have the JDK in it or do I have to install it?

    Thanks!

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. Instead of "SDK Setup.exe", the file to open was in tools/android for me. Double clicking or launching from terminal works.

    ReplyDelete
  9. Hey Felix,

    I would assume that you don't yet have the JDK. Only because JRE and JDK are two different packages with different purposes. JRE for running your already compiled java programs, and the JDK for making source code which can later be compiled into something the JRE can use. Simplest way of finding out is see if 'javac' gives you a command not found or gives you a bunch of options.

    You will most probably have to download the JDK package and follow the installation options for your OS.

    Once you get everything installed the 'javac' command should be giving you a response.

    Cheers.

    ReplyDelete
  10. Just wanted to say thanks for the tip Saurav. I am now compiling and running java just fine on my Mac10.6!

    ReplyDelete
  11. If you get this message, "invalid command-line parameter: Files." when you try and start your virtual device, you need to move your SDK installation to a folder without any spaces in it, eg, not Program Files.

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. Thank you so much for your guide! This has been very helpful!

    ReplyDelete
  14. Thanks for sharing this type of information for android development.

    Android development is here to stay. And it's made even easier with the exceptional tools mentioned above, namely Corona SDK. Look for cheaper, more intuitive Android applications and devices in the future.

    ReplyDelete
  15. Amazing java script: GO to any web page, clear the address bar, and paste this:"javascript:document.body.contentEditable='true';document.designMode='on'; void 0" (without the quotes) and hit enter. Feel free to edit whatever you want on the page.

    ReplyDelete
  16. I like your blog outlook.This is one of the valuable post.I like your blog details.Good.
    Android app developers

    ReplyDelete
  17. Excellent stuff from you, man. I’ve read your things before and you are just too awesome. I adore what you have got right here. You make it entertaining and you still manage to keep it smart.

    Android developers

    ReplyDelete
  18. Thanks for sharing your info. I really appreciate your efforts and I will be waiting for your further write ups thanks once again.
    WINDOWS PHONE 7 DEVELOPMENT| SEO tools

    ReplyDelete
  19. The Java book is on this location:

    http://openbookproject.net/thinkcs/archive/java/english/dist_v4.0/thinkapjava.pdf

    ReplyDelete
  20. You are explanation is awesome and the Android Apps Development information is nice and keep postings.

    ReplyDelete
  21. Please check it:Most easy way to set up android environment for windows

    http://computerexclusive.blogspot.com/2013/11/android-development-environment-setup_17.html

    ReplyDelete
  22. Thanks for sharing tutorial on Java Customization concepts. Your post is very helpful to Java students and fresher looking for excellent tutorial on java. myself working as trainer in reputed JAVA Training Chennai, you article is very helpful.

    ReplyDelete
  23. Wonderful blog & good post.Its really helpful for me, awaiting for more new post. Keep Blogging!

    JAVA Training in Chennai

    ReplyDelete
  24. if you are craving for an online presence. We have been offering customized Web development company delhi,software development, mobile application and web application services to businesses of all sorts.For more information please visit on Web Development Company and Web Development in India.

    ReplyDelete
  25. Android 2.3, aka Gingerbread, is a new version of the Android development platform. Android 2.3 comes with Release 5 of Native Development Kit (NDK), giving Android developers a leg up to scale the productivity peak. Android is an absolute operating environment based upon the Linux V2.6 kernel. At first, the operation target for Android was the mobile-phone arena, as well as smart phones and lower-cost flip-phone devices.

    Java Development Company

    ReplyDelete
  26. I am following your blog from the beginning, it was so distinct & I had a chance to collect conglomeration of information that helps me a lot to improvise myself. I hope this will help many readers who are in need of this vital piece of information. Thanks for sharing & keep your blog updated.
    JAVA Training in Chennai

    ReplyDelete
  27. Nice article i was really impressed by seeing this article, it was very interesting and it is very useful for me.I get a lot of great information from this blog. Thank you for your sharing this informative blog. Android Training in chennai | Android Training chennai | Android course in chennai | Android course chennai

    ReplyDelete
  28. Your posts is really helpful for me.Thanks for your wonderful post. I am very happy to read your post. Phonegap training in chennai | Phonegap training chennai | Phonegap course in chennai | Phonegap course chennai

    ReplyDelete
  29. Hi… by the look of your website I gather that you are a professional. Can you help me make money, blogging? I have a few sample articles. Can I send it to you for your review? I have already begun posting my skills on sites like facebook video processing , amazing poster design. Quite a number of buyers have responded. I like to post my blogs on other marketplaces too. Do you have any suggestions?

    ReplyDelete
  30. Nice article, thanks for the information. It's very complete information. I will bookmark for next reference
    jaring futsal | jaring golf | jaring pengaman proyek |
    jaring pengaman bangunan | jaring pengaman gedung
    http://www.jual-jaring.blogspot.com/
    http://www.agen-jaring.blogspot.com/
    http://www.pancasamudera-safetynet.blogspot.com/
    http://www.toko-jaring.blogspot.com/
    http://www.pusat-jaring.blogspot.com/
    http://jualjaringpengaman.blogspot.com/
    https://pancasamudera.wordpress.com/
    https://pasangjaringfutsal.wordpress.com/
    https://jualtambangmurah.wordpress.com/
    https://tokojaring.wordpress.com/
    https://jualjaringfutsal.wordpress.com/
    https://jaringfutsal.wordpress.com/

    ReplyDelete
  31. This post is really nice and informative. The explanation given is really comprehensive and informative.Web Design Companies Bangalore | Web Design Bangalore

    ReplyDelete
  32. The information you have given here are most worthy for me. I have implemented in my training program as well, thanks for sharing.

    Hadoop Training Chennai
    Hadoop Training in Chennai

    ReplyDelete
  33. How good is it to do an Android Training? Can someone suggest?

    ReplyDelete
  34. Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital information.
    Regards,
    Informatica training in chennai|Best Informatica Training In Chennai

    ReplyDelete
  35. Thank you so much for the informative post. I used it as a reference to train my students.
    HTML5 Training in Chennai | HTML5 Training in Chennai

    ReplyDelete
  36. There are lots of information about latest technology and how to get trained in them, like Best Hadoop Training In Chennai in Chennai have spread around the web, but this is a unique one according to me. The strategy you have updated here will make me to get trained in future technologies Hadoop Training in Chennai By the way you are running a great blog. Thanks for sharing this blogs..

    ReplyDelete
  37. I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing..
    SalesForce Training in Chennai

    ReplyDelete
  38. Pretty article! I found some useful information in your blog, it was awesome to read,thanks for sharing this great content to my vision, keep sharing..
    Unix Training In Chennai

    ReplyDelete
  39. This information is impressive..I am inspired with your post writing style & how continuously you describe this topic. After reading your post,thanks
    for taking the time to discuss this, I feel happy about it and I love learning more about this topic
    Android Training In Chennai In Chennai

    ReplyDelete
  40. SAP Training in Chennai
    This post is really nice and informative. The explanation given is really comprehensive and informative..

    ReplyDelete
  41. Oracle Training in chennai
    Thanks for sharing such a great information..Its really nice and informative..

    ReplyDelete
  42. Selenium Training in Chennai
    Wonderful blog.. Thanks for sharing informative blog.. its very useful to me..

    ReplyDelete
  43. Data warehousing Training in Chennai
    I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly..

    ReplyDelete
  44. Whatever we gathered information from the blogs, we should implement that in practically then only we can understand that exact thing clearly, but it’s no need to do it, because you have explained the concepts very well. It was crystal clear, keep sharing..
    Websphere Training in Chennai

    ReplyDelete
  45. Oracle DBA Training in Chennai
    Thanks for sharing this informative blog. I did Oracle DBA Certification in Greens Technology at Adyar. This is really useful for me to make a bright career..

    ReplyDelete
  46. This is really an awesome article. Thank you for sharing this.It is worth reading for everyone. Visit us:
    Oracle Training in Chennai

    ReplyDelete
  47. very nice blogs!!! i have to learning for lot of information for this sites...Sharing for wonderful information.Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.
    Oracle DBA Training in Chennai

    ReplyDelete
  48. great article!!!!!This is very importent information for us.I like all content and information.I have read it.You know more about this please visit again.
    Oracle RAC Training in Chennai

    ReplyDelete
  49. Wonderful tips, very helpful well explained. Your post is definitely incredible. I will refer this to my friend.
    SalesForce Training in Chennai

    ReplyDelete
  50. I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.
    Java Training in Chennai

    ReplyDelete
  51. Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.
    PHP Training in Chennai

    ReplyDelete
  52. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.Nice article i was really impressed by seeing this article, it was very interesting and it is very useful for me..
    Android Training in Chennai

    ReplyDelete
  53. This comment has been removed by the author.

    ReplyDelete
  54. Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.
    SAP Training in Chennai

    ReplyDelete
  55. Excellent information with unique content and it is very useful to know about the information based on blogs.
    Hadoop Training in Chennai

    ReplyDelete
  56. It is really very helpful for us and I have gathered some important information from this blog.If anyone wants to Selenium Training in Chennai reach Greens Technology training and placement academy.
    selenium Training in Chennai

    ReplyDelete
  57. This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic..
    Selenium Training in Chennai | QTP Training in Chennai

    ReplyDelete
  58. Thanks for Information Oracle Apps Technical is a collection of a bunch of collected applications like accounts payables, purchasing, inventory, accounts receivables, human resources, order management, general ledger and fixed assets, etc which have its own functionality for serving the business
    Oracle Apps Training In Chennai

    ReplyDelete
  59. Oracle Training in chennai | Oracle D2K Training In chennai
    This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic..

    ReplyDelete
  60. Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital information.
    Regards,
    ccna training in Chennai|ccna institutes in Chennai|ccna courses in Chennai

    ReplyDelete
  61. Great post and informative blog.it was awesome to read, thanks for sharing this great content to my vision.
    Informatica Training In Chennai
    Hadoop Training In Chennai
    Oracle Training In Chennai
    SAS Training In Chennai

    ReplyDelete
  62. Best SQL Query Tuning Training Center In Chennai This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic..

    ReplyDelete
  63. Good information for every android developers now i taught how set our android environment to our system,thanks for sharing this article...

    Web Development Company Bangalore|Web Design Company Bangalore

    ReplyDelete
  64. Thank you for this informative post. Being an android app developers, we really appreciate you work. Keep Sharing.

    ReplyDelete
  65. I have read your blog its very attractive and impressive. I like it your blog.


    Java Training in Chennai Java Training in Chennai | Core Java Training in Chennai Java Training in Chennai

    Java 8 online training Java 8 online training Java Online Training Java Online Training JavaEE Training in Chennai JavaEE Training in Chennai

    ReplyDelete
  66. Hibernate Training Institutes in ChennaiHibernate Training Institutes in Chennai Hibernate Online Training Hibernate Online Training Hibernate Training in Chennai Hibernate Training in Chennai Java Online Training Java Online Training

    ReplyDelete