Skip to main content
Version: 26.2.9

Android

Follow the instructions below to install and set up the Skillz SDK in your Android Studio project.

Add Required Maven Repositories

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. Make sure the one labeled Module is selected like so:

build dot gradle location

Add the Skillz repository like so:

android {
repositories {
// The Google Maven repository must be listed first
google()
maven {
url 'http://nexus.skillz.com/content/groups/public/'
}
}
}

Google's Maven repository (re: google()) must be listed first as Gradle won't look past the first Maven repository if it finds an older version of a dependency.

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 earlier:

android {
// Extra code excluded for brevity
}

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

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

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 23 or higher, and works best with a compiledSdkVersion of 28 and targetSdkVersion of 28. 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 28

defaultConfig {
minSdkVersion 23
targetSdkVersion 28
ndk {
abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
}

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

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

You must also include the abiFilters line in order to support both 32-bit and 64-bit devices.

Add multidex-keep.txt

The Skillz SDK needs a few classes to end up in your APK's main DEX file upon compilation. Modify build.gradle to reference a file called multidex-keep.txt inside the defaultConfig subsection for the android section.

android {
defaultConfig {
multiDexKeepProguard file('multidex-keep.txt')
}
}

Now, add a file called multidex-keep.txt to your Android Studio project with the contents below:

# multidex-keep.txt
-keep class io.fabric.sdk.android.** { *; }
-keep class timber.log.** { *; }
-keep class com.facebook.FacebookSdk
-keep class com.path.android.jobqueue.JobManager

Enable AndroidX

The Skillz SDK depends on the AndroidX Support Libraries instead of the original Android Support Libraries. In your project, add the lines below to the gradle.properties file; create one if it does not exist. These will tell Android Studio to automatically migrate dependencies from any original Support Libraries to their AndroidX equivalents.

android.useAndroidX=true
android.enableJetifier=true

Upgrade to Java 8

Since the SDK uses Java 8, you’ll also need to update to that version of Java to ensure compatibility.

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

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 console, and sync your game to Production. Prior to that, you may see artifacts within your custom theme.

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="com.packagename.GameActivityName" />
<meta-data android:name="skillz_allow_exit" android:value="true" />
<meta-data android:name="skillz_exit_activity" android:value="com.packagename.MenuActiviyName" />
</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 Console. You can obtain your Game ID by going to your developer console.


<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 console, 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 false if your game is Skillz-only and there is no main menu of your game. Set the value to true to allow users to exit the Skillz interface back to the main menu of your game. If you set the value of skillz_allow_exit to true, you must also provide the skillz_exit_activity for Skillz to return to. Otherwise, the screen will be blank.


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

Set the value to the name of the activity Skillz should launch when a user exits the Skillz menu UI. Skillz requires a fully-qualified path, example: "com.skillzgames.caverun.MainMenuActivity". This value is only used when skillz_allow_exit is true.


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" />

Change the main activity's launchMode to singleTop

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

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="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

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 {
}

Make sure your build.gradle Syncs sucessfully, and that your project still compiles. If so, you're now ready to integrate the Skillz SDK.