Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Compile Sample Code

I'm breaking into GUI programming with android, trying to compile and analyze Lunar Lander sample program. The instructions for using Eclipse say to select "Create project from existing source" but that option doesn't exist. If I select File->New->Project I can select "Java project from Existing Ant Buildfile". Using that I've tried selecting various xml files as "Ant Buildfile" but all give me the "The file selected is not a valid Ant buildfile" error.

I just want to run GUI sample projects, preferably with Eclipse. Any useful tips will be appreciated.

like image 539
James L Avatar asked Dec 18 '22 00:12

James L


2 Answers

First of all you need to install Eclipse ADT plugin, here are the instructions http://developer.android.com/guide/developing/eclipse-adt.html.

Then you can import sample code in two ways:

  1. File -> New -> Android Project, and choose "Create project from existing source"
  2. If it is already an Eclipse project, click File -> Import, after that right click on the Project and choose Make it an Android Project
like image 96
ZelluX Avatar answered Dec 19 '22 14:12

ZelluX


I read you prefer Eclipse, but you can always work from command line.

In a GNU/Linux system it's possible to do

$ cp -r $ANDROID_SDK/samples/android-15/LunarLander .
$ android update project --path LunarLander/ --target 3 --subprojects
$ cd LunarLander/
$ ant debug install

You have to choose the target according to your system. It's possible to pick one id from the list you get with this command

$ android list targets 
like image 26
MaxChinni Avatar answered Dec 19 '22 14:12

MaxChinni