This sample demonstrates how an application can make use of shared code and resources stored in an Android library project.

In this case, the TicTacToeMain application project includes a reference to the TicTacToeLib library project. When you build the TicTacToeMain application, the build tools look for the library project and compile it's code and resources as part of the main application's `.apk` file. The main application is designed with a launcher activity called `MainActivity`, shown at left, below. When the user presses a button in the View, `MainActivity` starts a second activity, `GameActivity`, which is declared in the library project.

- The main application's AndroidManifest.xml file contains declarations of both `MainActivity`, which is implemented locally in main project, and `GameActivity`, which is implemented in the library project. Currently, an application must declare in its manifest any components or resources that it is using from a library project.
- MainActivity.java shows how a class in the main application imports and uses classes from the library project. The Activity sets listeners on the buttons in the main View and, when one of them is clicked, creates an explicit Intent targeted at the `GameActivity` component declared in the TicTacToeLib library project.

The TicTacToeLib library project includes a single Activity, `GameActivity`, that handles most of the application lifecycle.

- The library project includes an AndroidManifest.xml file that declares `GameActivity`.
- GameActivity.java handles most of the application lifecycle and manages general game play.
- GameView.java renders the UI of the game and manages interaction events during game play.

If you want to build the TicTacToeMain application, you can obtain it by downloading the "Samples for SDK API 8" component (or higher version) into your SDK, using the Android SDK and AVD Manager. Note that the application project depends on code and resources found in the TicTacToeLib library project — in order to build TicTacToeMain, you need to add both projects to your development environment.

To build an application that uses a library project, you also need to update to the latest version of the SDK tools (r6 or higher) and Android platforms, as well as the latest version of ADT (0.9.7 or higher), if you are developing in Eclipse.

For information about how to set up Android library projects, refer to Developing in Eclipse with ADT or Developing in Other IDEs, depending on your environment.