Adding the Skillz Library

 

These steps will teach you how to add the Skillz SDK to your project. 

Step 1: Add Skillz Maven Repository

The Skillz Android SDK and its dependencies reside in the Skillz maven repository. In your build.gradle file, you will need to add this maven repository so that it can later add the Skillz SDK to your project.

Add the Skillz repository like so:

repositories { 
     maven { 
         url 'http://nexus.skillz.com/content/groups/public/' 
     } 
maven {
url 'https://maven.google.com'
} }

Step 2: Adding the Skillz SDK Dependency

Next, add the Skillz library as a dependency. In this step, you must choose to add either the Stable build or the Beta build of the Skillz Android SDK. If you’re not sure which build is right for you, click here to find the release notes on each build. (For managed accounts, please reach out to your Skillz Account Manager for guidance on which build to integrate.)

To integrate the latest Stable build, add the following in the same build.gradle file you edited in Step 1:

dependencies {
    ...
    compile 'com.skillz.sdk:skillz-sdk-android:18.0.5'
    ...
}

To integrate the latest Beta build, add the following in the same build.gradle file you edited in Step 1: 

dependencies {
    ... 
    compile 'com.skillz.sdk:skillz-sdk-android:18.0.14'
    ...
}
 

Note: When upgrading to newer Skillz SDK releases in the future, you’ll need to update these version numbers ("18.0.5" or "18.0.14" in the above example) within your project.



Step 3: Ensure Android SDK version compatibility

 

In your build.gradle file, you will need to ensure the Android SDK version compatibility. Skillz requires a minSdkVersion of 19 or higher, and works best with a compiledSdkVersion of 25 and targetSdkVersion of 22. If you want to learn more about what's the difference between compiledSdkVersion and targetSdkVersion, you can check out the official Android developer documentation.

Android {
   compileSdkVersion 25
   buildToolsVersion "25.0.2"

   defaultConfig {
      applicationId "com.skillzgames.caverun"
      minSdkVersion 19
      targetSdkVersion 22
   }
}

A targetSdkVersion of 23 (6.0) or higher will cause permission problems. Users may be repeatedly asked to grant location permissions, even if they have done so in the past. This is due to the new on-demand permissions paradigm introduced with this version of Android. Setting your targetSdkVersion values to 22 will avoid these issues.

Ensure minSdkVersion is set to 19 or higher and that the targetSdkVersion is set to 22 or higher within the android { defaultConfig { } } block of your build.gradle file.

Additionally, ensure that the compiledSdkVersion within the android block is set to 25 or lower.

Finally, set the uses-sdk line within the <manifest> block of your AndroidManifest.xml file to match these settings:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.skillz.caverun" />
    <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="22" /> 

 

Step 4: Setting Skillz meta-data

 

Add the following lines in your Android Manifest’s <application> block:

<application>
    <!-- Make sure the Skillz <meta-data> tags are all direct children of the <application> tag, otherwise the game won't run properly! -->
    <meta-data android:name="skillz_game_id" android:value="" />
    <meta-data android:name="skillz_production" android:value="false" />
    <meta-data android:name="skillz_game_activity" android:value="" />
    <meta-data android:name="skillz_allow_exit" android:value="true" />
</application>

Now, edit each meta-data line to contain the correct information for your game.

<meta-data android:name="skillz_game_id" android:value="" />

Set the value to your Skillz Game ID from the Skillz Developer Portal. You can obtain your Game ID by going to your developer portal.

<meta-data android:name="skillz_production" android:value="false" />

Set this value to “false” for testing in the sandbox environment. When you are ready to move to production and before uploading a binary in your developer portal, set this value to “true”.

<meta-data android:name="skillz_game_activity" android:value="" />

Set the value to the name of the activity Skillz should launch when a user enters a Skillz match. Skillz requires a fully-qualified path, example: “com.skillzgames.caverun.GameActivity”.

<meta-data android:name="skillz_allow_exit" android:value="true" />

Set the value to “true” to allow users to exit the Skillz interface back to the main menu of your game. Set the value to “false” if your game is Skillz-only and there is no main menu of your game.

  Screen_Shot_2017-10-23_at_5.43.51_PM.png

Note: You may need to add this meta-data tag 

<meta-data android:name="android.max_aspect" android:value="2.1" /> 
to support the larger aspect ratio of the new Android flagship phones.

  

Step 5: Game Activity should extend from SkillzActivity

The activity that you specified in the meta-data tag “skillz_game_activity” will need to inherit from SkillzActivity.

Example:

Public class GameActivity extends SkillzActivity {

Note: This Step is required for Skillz SDK versions 18.0 and up.

 

Step 6: Configuring FCM push notifications (Optional)

 

GCM has been deprecated by Google and made Firebase Cloud Messaging their new push notification system. Skillz now support this feature. You can learn how to set up FCM here. If you have already integrated GCM in your game and would like to migrate to FCM, you can read about that here.

 

Next Steps

After completing these steps, the Skillz SDK should be properly included in your project and you should be able to compile your game without errors.

The next step is to perform the core integration!