How to compose a sample code

I broke into GUI programming using android, trying to compile and analyze the Lunar Lander trial program. Eclipse instructions say to select "Create a project from an existing source", but this option does not exist. If I select File-> New-> Project, I can select "Java project from existing Ant Buildfile". Using this, I tried to select various xml files as "Ant Buildfile", but everyone gives me "the selected file is not a valid Ant buildfile error."

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

+4
source share
4 answers

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

You can then import the sample code in two ways:

  • File β†’ Create β†’ Android Project and select β€œCreate Project from Existing Source”
  • If it is already an Eclipse project, click "File β†’ Import", then right-click Project and select "Make It An Android Project"
+7
source

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

On a GNU / Linux system, you can do

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

You must choose a target according to your system. You can select one identifier from the list that you get with this command.

 $ android list targets 
+5
source

It should be File-> New-> Android Project, which you need to select. Apparently you have not installed the Android SDK

0
source

In the past, you could use "ant" to compile:

https://tthtlc.wordpress.com/2015/08/01/how-to-quickly-compile-all-the-android-samples-via-command-line/

But since June 2014, the SDK has been encouraging users to migrate to use gradle, but these are scammers with a lot of problems. By June 2015, the compilation was mostly successful. Here are the steps:

https://tthtlc.wordpress.com/2015/10/30/how-to-build-android-sdk-samples-using-gradle/

And a complete compilation of all samples under the "android-22" branch: I have 84 successful and 19 failures.

Complete magazines are available here:

http://pastebin.com/33JBDAqj

0
source

Source: https://habr.com/ru/post/1310317/


All Articles