SDK Configuration

Prerequisites

  • Android Studio 0.5.8 or greater
  • Android 4.3 (API 18) or greater
  • local Maven installation 

Integrating the SDK

The SDK is delivered as an .aar library. While not widely adopted, or clearly documented, the aar format does work. There are two ways to integrate the SDK into an Android Studio project.
Note: Android Studio and the .aar format for libraries are still under active development, and may change.

Integrating with Local Maven

Using the local maven repo was the approach used during development. This requires Maven, and was developed on OS X 10.92 using Maven 3.2.1 installed using Brew. An example Gradle task to upload the aar would be similar to the following:
apply plugin: 'maven'
// This would change according to the version and name of the aar
def builtAarFile = file('NikeSDK-0.1.0.aar') 

artifacts {
    archives builtAarFile
}

uploadArchives() {
    repositories {
        mavenDeployer {
            // Modify this to match the path to your local Maven repository. This is an example of the default .m2/repository path
            // in the user's home directory
            repository url: 'file://' + new File(System.getProperty('user.home'), '.m2/repository').absolutePath
            pom.groupId = 'com.nike'
            pom.artifactId = 'NikeSDK'
            pom.version = '0.1.0'
        }
    }
}
Once this has completed successfully, adding the Nike SDK to your project requires adding a dependency to your Gradle build file, and referencing the local Maven repository.
// Sample build configuration
apply plugin: 'android'

android {
// Configure other project dependencies

  // Add the dependency here
  dependencies {
      compile 'com.nike:NikeSDK:0.1.0@aar'
  }

    repositories {
        mavenLocal()
    }
}

Integrating with Directory Based Configuration

An alternative method of integrating the SDK in the project is by using a directory based approach. The directory is listed as a flatDir, while the .aar listed in the compilation block as in the local repository approach.
AndroidAarFlatDir
repositories {
    flatDir(){
        dirs 'thirdPartyLibraries'
    }
}
dependencies {
   // This would change according to the version and name of the aar
    compile 'com.nike:NikeSDK:0.1.0@aar'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:19.+'
}