1. Integrate the SDK into your project

You can integrate Apigee features into your app by including the SDK in your project.  You can do one of the following:

If you've already got an Android project, you can integrate the Apigee SDK into your project as you normally would:

Add apigee-android-<version>.jar to your class path by doing the following:

Android 4.0 (or later) projects

Copy the jar file into the /libs folder in your project.

Android 3.0 (or earlier) projects

  1. In the Eclipse Package Explorer, select your application's project folder.
  2. Click the File > Properties menu.
  3. In the Java Build Path section, click the Libraries tab, click Add External JARs.
  4. Browse to apigee-android-<version>.jar, then click Open.
  5. Order the apigee-android-<version>.jar at the top of the class path:
    1. In the Eclipse Package Explorer, select your application's project folder.
    2. Click the File > Properties menu.
    3. In the properties dialog, in the Java Build Path section, click the Order and Export tab.
    4. IMPORTANT: Select the checkbox for apigee-android-<version>.jar , then click the Top button.

Applications using Ant

If you are using Ant to build your application, you must also copy apigee-android-<version>.jar to the /libs folder in your application.

If you don't have a project yet, you can begin by using the project template included with the SDK. The template includes support for SDK features.

2. Update permissions in AndroidManifest.xml

Add the following Internet permissions to your application's AndroidManifest.xml file if they have not already been added. Note that with the exception of INTERNET, enabling all other permissions are optional.

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

3. Initialize the SDK

To initialize the App Services SDK, you must instantiate the ApigeeClient class. There are multiple ways to handle this step, but we recommend that you do the following:

  1. Subclass the Application class, and add an instance variable for the ApigeeClient to it, along with getter and setter methods.
    public class YourApplication extends Application
    {
            
            private ApigeeClient apigeeClient;
            
            public YourApplication()
            {
                    this.apigeeClient = null;
            }
            
            public ApigeeClient getApigeeClient()
            {
                    return this.apigeeClient;
            }
            
            public void setApigeeClient(ApigeeClient apigeeClient)
            {
                    this.apigeeClient = apigeeClient;
            }
    }			
    		
  2. Declare the Application subclass in your AndroidManifest.xml. For example:
    <application>
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:name=".YourApplication"
    	…
    </application>			
    		
  3. Instantiate the ApigeeClient class in the onCreate method of your first Activity class:
    import com.apigee.sdk.ApigeeClient;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);		
    	
    	String ORGNAME = "{{currentOrg}}";
    	String APPNAME = "{{currentApp}}";
    	
    	ApigeeClient apigeeClient = new ApigeeClient(ORGNAME,APPNAME,this.getBaseContext());
    
    	// hold onto the ApigeeClient instance in our application object.
    	YourApplication yourApp = (YourApplication) getApplication;
    	yourApp.setApigeeClient(apigeeClient);			
    }
    		

    This will make the instance of ApigeeClient available to your Application class.

4. Import additional SDK classes

The following classes will enable you to call common SDK methods:

import com.apigee.sdk.data.client.DataClient; //App Services data methods
import com.apigee.sdk.apm.android.MonitoringClient; //App Monitoring methods
import com.apigee.sdk.data.client.callbacks.ApiResponseCallback; //API response handling
import com.apigee.sdk.data.client.response.ApiResponse; //API response object

5. Verify SDK installation

Once initialized, App Services will also automatically instantiate the MonitoringClient class and begin logging usage, crash and error metrics for your app.

screenshot of data in admin portal

To verify that the SDK has been properly initialized, run your app, then go to 'Monitoring' > 'App Usage' in the App Services admin portal to verify that data is being sent.

It may take up to two minutes for data to appear in the admin portal after you run your app.

Installation complete! Try these next steps