Creating New Applications


In order to ease the creation of new Android JNI native/Java samples that can be built from Eclipse, the SDK includes a bash shell script that generates new projects from a selection of templates. This tool is called app_create. It can create new applications in subdirectories of user_apps/ that can be used as the basis for more complex application projects. To use the script, do the following:

  1. Choose a path name for the application, e.g., my_app. A directory of the given name under user_apps/ must NOT already exist prior to running the script, or the script will fail. This is a safety measure to avoid overwriting existing code.
  2. Choose a Java package name for the application, e.g., com.mycorp.myapp
  3. Choose a Java class name for the application, e.g., MyApp.
  4. Select your desired application template. The options are:
  5. Open a Cygwin/bash shell to the SDK’s tools\app_create directory.
  6. Run the script: 
    ./app_create.sh <app path name> <app java name> <template name>

    For example: 
    ./app_create.sh my_app MyApp nv_event

This will result in the new application being created in the indicated subdirectory of user_apps/. To load the new application into Eclipse for building, simply re-run the steps previously mentioned for Setting up the Eclipse workspace, selecting only the new project from the project import dialog. The new application project should be added to your workspace.

The project may be treated exactly like any other project in the SDK. New source files may be added to the app’s jni directory and Makefile, an assets directory, may be created and filled with assets for the APK, and additional settings may be added to the AndroidManifest.xml.

The basic template is based directly on the sample app native_basic, which is a pure native NativeActivity/nv_native_app_glue application. The subclass template is based directly on the android feature demo native_subclass, which includes app-written Java code.

Moving an App_Create-Generated Application

If you need to move an app_create-based application after creating it, note that the applications created with this script make relative-path reference to the samples pack’s libs/jni directory. So if you move the application, you must change the app’s jni/Android.mk line:

$(call import-add-path, ../../../libs/jni) 

To reference the correct absolute or relative path to the samples pack’s libs source tree, or else the application will not build.

 

 


NVIDIA® GameWorks™ Documentation Rev. 1.0.200601 ©2014-2020. NVIDIA Corporation. All Rights Reserved.