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 the module-level build.gradle file (it can be found in the src folder where your game resides, not at the top level), you will need to add this maven repository so that it can later add the Skillz SDK to your project.

On Android Studio in the Android view on the Project panel, there are two build.gradle files: one labeled Project and one labeled Module. The one labeled Module is selected.

Add the Skillz repository like so:

android {
...
repositories {
... google()
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:

android {
...
}

dependencies {
    ...
    implementation 'com.skillz.sdk:skillz-sdk-android:21.0.14'
    ... }

Note: When upgrading to newer Skillz SDK releases in the future, you’ll need to update these version numbers ("21.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 27 and targetSdkVersion of 27. 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 27
    buildToolsVersion "25.0.2"

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 27
    }
ndk {
abiFilters "armeabi-v7a", "x86"
}
... }

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

Additionally, ensure that the compileSdkVersion within the android block is set to 27.

You must also include the "ndk { abiFilters ... }" line in order to build on 32bit ABIs, as Skillz does not support 64bit ABIs yet.

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="YOUR.PACKAGE.NAME" />
    <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="27" /> 
   ...
</manifest>

 

Step 4: Upgrade to Android 8

 Since our SDK now uses Android 8, you’ll also need to update to Android 8 to ensure compatibility.

android {
...
   compileOptions {
       sourceCompatibility JavaVersion.VERSION_1_8
       targetCompatibility JavaVersion.VERSION_1_8
   }
...
}

 

Step 5: Update your proguard.txt

This update makes use of the libraries shown below. Please add the following lines to your existing Proguard file so that the Android project can compile correctly.

-keep public class com.dylanvann.fastimage.* { *; }
-keep public class com.dylanvann.fastimage.** { *; }
-keepclassmembers enum * {
   public static **[] values();
   public static ** valueOf(java.lang.String);
}

-keep class com.scottyab.rootbeer.** { *; }

Custom Theming Warning - If your game takes advantage of our custom themed SDK feature, you will need to build an .ipa or .apk with the new SDK version, upload it to our developer portal, and sync your game to Production. Prior to that, you may see artifacts within your custom theme.

 

Step 6: 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.

 

Note: You may need to add the following meta-data tag to support the larger aspect ratio of the new Android flagship phones:
<meta-data android:name="android.max_aspect" android:value="2.1" />

 

Step 7: Change the main activity's launchMode to singleTask 

Inside your AndroidManifest.xml file, set your main activity’s launchMode to singleTask

NOTE: For Unity Android games, launchMode should be set to singleTop instead. See here for more information. 

Your main activity is the one with an intent filter with an action set as MAIN and category of LAUNCHER.

<activity 
  android:name=".YourMainActivity"
  android:launchMode="singleTask">
  <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter> </activity>

 

Step 8: 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 9: 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.

 

Step 10: Runtime Permissions and Background Operations (Optional)

What does the Android SDK Upgrade mean for you?

The following steps explain what tasks you may need to complete to upgrade your application to Android SDK 27. Since 20.x to 21.x is moving from Android API 22 to Android API 27, there are various changes you may need to incorporate into your game to fulfill all compatibility concerns.

 

Runtime Permissions

The biggest change here is that any permissions you request from the user will now need be requested at runtime, rather than at install time. Documentation for that can be found here

 

Background Operations

As of Android 26, if your game uses background processing, you’ll need to ensure they conform to the newest protocols.  Documentation for that can be found here.

After completing these steps, your game will be compatible with Android 27, and can compile your game without errors.

 

Additional Resources

If you are having issues even after these steps, docs from Google explaining the changes in each SDK version can be found below: 

 

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. Your game should run how it did before. 

The next step is to perform the core integration!