Platform: OpenFeint Android SDK 1.6

Readme.html for OpenFeint Android SDK 1.6
Release date 12.15.2010
Release Notes Copyright (c) 2009-2010 Aurora Feint Inc.
All Rights Reserved.

OpenFeint Android Quick Start Guide


<<Prev Next >>
 

Build and run the OpenFeint Sample Application

The sample app lets you experiment with the features you've configured on the OpenFeint dev dashboard before you've begun to write your own app. Once you do begin working with your own app, it is frequently helpful to come back to the sample app to compare how individual features work and how they are implemented.


  • Build and run the OpenFeint Sample App for Android in Eclipse

    NOTE: The following instructions assume you are using a standard installation of the Android SDK with the Eclipse IDE as described at http://developer.android.com/sdk/index.html. Adjustments may be required if your development environment is set up differently. The "Hello World" sample app tutorial at http://developer.android.com/sdk/index.html is recommended as a good way to test that your development environment is set up properly.

    1. Save the Contents of the OpenFeint Android SDK package in a convenient location. Everything you need from this package to build the sample app is in the directory called MyOpenFeintSample. You may copy this directory out of the package and rename it if you want to use it as a starting point for experimental code.
    2. To develop in Eclipse:
      1. Open Eclipse with an empty workspace. This will present an empty "Project Explorer" pane to which you will add a reference to the sample app project.
      2. Make sure that the path to your Android SDK has been set for this workspace. To set it, go to Eclipse-->Preferences-->Android-->SDK Location.
      3. Add the sample app project to the workspace:
        • Right click in the empty Project Explorer pane and select Import.
        • Select General -->Existing Projects into Workspace from the import dialog.
        • Click the Next button.
        • Click Select root directory. Click Browse. Navigate to the MyOpenFeintSample directory in the OpenFeint package.
        • Click Open.
        • Click the Finish button.
        • The MyOpenFeintSample is now listed in the project window.
          Clicking the triangle next to MyOpenFeintSample should reveal an outline like this:
          Project OK
      4. Add your product information to the sample app:
        1. Bring up the OpenFeint developer dashboard ( https://api.openfeint.com/dd) in a browser. Choose the game you will use with the sample application. Click the Application Information button to show the properties of the application you defined:
          App Properties
        2. In Eclipse, edit MyOpenFeintSample/src/com.openfeint.example/OpenFeintApplication.java; construct your OpenFeint settings object using the game name, game ID, game key, and game secret of your game as defined on the OpenFeint developer site:
          1. The values can be set in the class definition of the source code of your main activity:
            static final String gameName = "Name of your application";
            static final String gameID = "gameID";
            static final String gameKey = "gameKey";
            static final String gameSecret = "gameSecret";
            
            For example, in the sample application, you could add these lines in src/com.openfeint.example/OpenFeintApplication.java after:
            public class OpenFeintExample extends ListActivity {
            
          2. Use the variables you defined to construct your settings object. This can be done in the onCreate() method of your main activity:
            OpenFeintSettings settings = new OpenFeintSettings(gameName, gameKey, gameSecret, gameID);
            
            For example, in the sample application, you could add this line into the onCreate() method in src/com.openfeint.example/OpenFeintApplication.java.
        3. Initialize OpenFeint. This is typically done in the onCreate() method of your main activity.
          Add the the following line into the onCreate() method in your source code:
          OpenFeint.initialize(this, settings, new OpenFeintDelegate() {});
          
          For example, in the sample application, you could add this line into the onCreate() method in src/com.openfeint.example/OpenFeintApplication.java. Make sure you call OpenFeint.initialize() after you've set the values in the settings object.

      5. Add the OpenFeint SDK project to the workspace:
        • Right click in the empty Project Explorer pane and select Import.
        • Select General -->Existing Projects into Workspace from the import dialog.
        • Click the Next button.
        • Click Select root directory. Click Browse. Navigate to the sdk directory in the OpenFeint package.
        • Click Open.
        • Click the Finish button.
        • The OpenFeintAPI is now listed in the project window.
          Clicking the triangle next to MyOpenFeintSample should reveal an outline like this:
          SDK OK
      6. Try building the project to confirm that there are no build errors.
        • If Project -->Build Automatically is checked, the project will try to rebuild itself whenever its binaries are not up to date with its sources and will likely be ready to run or debug on a connected device.
        • If Project -->Build Automatically is not checked, you can manually request a build with Project--> Build Project.
        • If there are build errors, a mark appears over the project icon the list of errors appears in the Markers pane:
          Project Error
        • If you see an error that reads something like Project 'MyOpenFeintSample' is missing required source folder: 'gen'" or if Eclipse cannot create R.java, add the gen/ directory to the Project.
        • If you see a similar error for the OpenFeintAPI project, add the gen/ directory to the Project.
          Note: Visit this list for solutions to some common build errors.
      7. Run the sample application on an Android device or simulator.
        • You may use a USB cable to attach an Anrdoid device if configured for remote debugging or allow the Android simulator to be used if no device is attached.
        • Click the Run button or select Run from the Run menu.
        • If the Run As dialog appears, select Android Application and click OK.
          Run As

          If successful, the sample app displays a list of OpenFeint features that you can test.
  • Build and run the OpenFeint Sample App for Android in Ant
    1. Register an application using the OpenFeint developer dashboard at https://api.openfeint.com. There are step by step instructions here.
    2. Download the latest version of the OpenFeint SDK for Android.
    3. Extract the package.
    4. Run android.bat update lib-project –p /sdk/
    5. Add the line android.library.reference.1=FullPathToOpenFeintPackage/sdk/ to the build.properties file of the game
    6. Copy the entire MyOpenFeintSample directory from the SDK download (It should be in the download/OpenFeint.1.0.1 folder) into the new directory you've created.
    7. Copy the entire sdk directory from the download/OpenFeint.1.0.1 folder into the root of the new directory.
    8. Open the MyOpenFeintSample/com/openfeint/example/OpenFeintApplication.java file and provide your game's name, key, secret, and id to OpenFeintSettings. You can find these in the developer dashboard at https://api.openfeint.com.
    9. Open a terminal window.
    10. Change your working directory to the location to which you extracted OpenFeint:
      cd MyOpenFeintExample
      android update project -p .
      ant debug