ANDROID PROJECT

YOUR ANDROID PROJECTS – TUTORIAL

YOUR FIRST ANDROID PROJECT

For your initial android project, there are 2 major steps for obtaining started with Android: (android projects)

  1. You want to install the Android SDK and developer tools
  2. you must build a check project to substantiate that those tools are properly installed and organized

If you’ve got not however put in the Android SDK and related tools, click this link which covers this method. Once you’ve got the Android SDK, it’s time to form your initial android project. The nice news is that this needs zero lines of code – Android’s tools produce a “Hello, world!” application for you as a part of making a new project. All you would like to do is build it, install it, and see it return upon your somebody or device. That’s what this tutorial is for.

Step #1: Create the New Project

Android’s tools will produce a whole skeleton project for you, with everything you need for a whole (albeit terribly trivial) android application. The sole real distinction comes from whether you’re using Eclipse or the command line. (Android projects)

Step #1: Eclipse

From the Eclipse main menu, opt for File | New | Project…, and this will refer a listing of project types to settle on from. Fold open the android choice and click on android Project:

Eclipse New Project WizardFigure 1. Eclipse New Project Wizard

Press Next to advance the wizard to the most android project page:

Eclipse New Project Wizard, Android ProjectFigure 2. Eclipse New Project Wizard, Android Project

Fill in the following:

  • The name of the project (e.g., Now)

  • The Android SDK you wish to compile against (e.g., Google APIs for Android 2.3)

  • The name of the Java package in which this project goes (e.g.,com.commonsware.android.skeleton)

  • The name of the initial activity to create (e.g., Now)

Eclipse New Project Wizard, Android Project (continued)Figure 3. Eclipse New Project Wizard, Android Project (continued)

At this point, clicking Finish will create your Eclipse project.

Step #2: Command Line

Here  is  a sample command  that creates an  Android project  from  the command line:

android  create  project  –target   “Google  Inc.:Google  APIs:7” –path  Skeleton/Now

–activity  Now  –package  com.commonsware.android.skeleton

This will produce an application skeleton for you, complete with everything you would like to create your initial android application: Java source code, build directions, etc. However, you’re probably going to wish to customise this somewhat. Here are what those command-line switches mean:

  • –target indicates what version of Android you are “targeting” in terms of your build process. You need to supply the ID of a target that is installed on your development machine, one you downloaded via the SDK and AVD Manager. You can find out what targets are available via the android list targets command. Typically, your build process will target the newest version of Android that you have available.

  • –path indicates where you want the project files to be generated. Android will create a directory if the one you name does not exist. For example,  in the command shown above,  a  Skeleton/Now/directory will be created (or used if it exists) underneath the current working directory, and the project files will be stored there.

  • –activity indicates the Java class name of your first activity for this project. Do not include a package name, and the name has to meet Java class naming conventions.

  • –package indicates the Java package in which your first activity will be located. This package also uniquely identifies your project on any device on which you install it, and this package also needs to be unique on the Android Market if you plan on distributing your application there.  Hence,  typically, you construct your package based on a domain name you own (e.g.,com.commonsware.android.skeleton), to reduce the odds of an accidental package name collision with somebody else.

Your development machine, you may have to be compelled to choose an appropriate target, and you’ll like to alter the trail. The activity and package you’ll forbear for now. (Android projects)

Step #2:

Build, Install, and Run the Application in Your Emulator or Device

Having a project is good and all, but it might be even higher if we might build and run it, whether on the android somebody or your android device. Once again, the method differs somewhat reckoning on whether you’re using Eclipse or not.

Step #1: Eclipse

With your project chosen within the Package Explorer pane, click the green “play” button within the Eclipse toolbar to run your project. The primary time you are doing this, you may have to bear a number of steps to line up a “Run configuration”, and thus Eclipse knows what you wish to do.

First, within the “Run As” list, opt for “Android Application”:

Eclipse "Run As" ListFigure 4. Eclipse “Run As” List

If you’ve got over one emulator AVD or device access, you will then get a choice to opt for that you want to run the application on. Otherwise, if you do not have a tool blocked in, the emulator can initiate with the AVD you created earlier. Then, Eclipse can install the application on your device or emulator and begin it up.

Step #2: Command Line

For developers not using Eclipse, in your terminal, amendment into the Skeleton/Now directory, then run the subsequent command.

ant  clean  install

The Ant-based build ought to emit a listing of steps involved within the installation method, that look like this

Buildfile:  /home/some-balding-guy/projects/Skeleton/Now/build.xml [setup]  Android  SDK  Tools  Revision  8

[setup]  Project  Target:  Google  APIs
[setup]  Vendor:  Google  Inc.

[setup]  Platform  Version:  2.1-update1
[setup]  API  level:  7

[setup]

[setup]  ——————

[setup]  Resolving  library  dependencies:
[setup]  No  library  dependencies.
[setup]

[setup]  ——————
[setup]

[setup]  WARNING:  No  minSdkVersion  value  set.  Application  will  install  on  all Android  versions.

[setup]

[setup]  Importing  rules  file:  tools/ant/main_rules.xml

clean:

[delete]  Deleting  directory  /home/some-balding-guy/projects/Skeleton/Now/bin

-debug-obfuscation-check:

-set-debug-mode:

-compile-tested-if-test:

-dirs:

[echo]  Creating  output  directories  if  needed…

[mkdir]  Created  dir:  /home/some-balding-guy/projects/Skeleton/Now/bin

[mkdir]  Created  dir:  /home/some-balding-guy/projects/Skeleton/Now/gen

[mkdir]  Created  dir:  /home/some-balding-guy/projects/Skeleton/Now/bin/classes

-pre-build:

-resource-src:

[echo]  Generating  R.java  /  Manifest.java  from  the  resources…

-aidl:

[echo]  Compiling  aidl  files  into  Java  classes…

-pre-compile:

compile:

[javac]  /opt/android-sdk-linux/tools/ant/main_rules.xml:361:  warning:

‘includeantruntime’  was  not  set,  defaulting  to  build.sysclasspath=last;  set  to false  for  repeatable  builds

[javac]  Compiling  2  source  files  to  /home/some-balding-
guy/projects/Skeleton/Now/bin/classes

-post-compile:

-obfuscate:

-dex:

[echo]  Converting  compiled  files  and  external  libraries  into  /home/some-
balding-guy/projects/Skeleton/Now/bin/classes.dex…

-package-resources:

[echo]  Packaging  resources

[aapt]  Creating  full  resource  package…

-package-debug-sign:

[apkbuilder]  Creating  Now-debug-unaligned.apk  and  signing  it  with  a  debug  key…

debug:

[echo]  Running  zip  align  on  final  apk…

[echo]  Debug  Package:  /home/some-balding-guy/projects/Skeleton/Now/bin/Now-
debug.apk

BUILD  SUCCESSFUL

Total  time:  4  seconds

  • Note the BUILD  SUCCESSFUL at the bottom  – that is how you know the application compiled successfully.

When you have a clean build, in your emulator or device, open up the application launcher, usually found at the lowest of the home screen:

Android emulator application launcherFigure 5. Android emulator application launcher

Notice there’s an icon for your new application. Click on that to open it and see your initial activity in action. to go away the application and come back to the launcher, press the “BACK button“, set to the correct of the [MENU] button, and appears like an arrow in the form to the left. (Android projects)

BUILD UP A “LUNCH LIST” APPLICATION

Picture By

This post contains content of the book Android Programming Tutorials by Mark L. Murphy below is the link of the complete book Android Programming Tutorials