Skip to main content

Android

This article will walk you through installing the Skillz SDK in your native Android project.

note

If you are developing in Unity, follow the Unity instructions, instead.

1. 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.

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

build dot gradle location

Add the Skillz repository URL:

build.gradle
android {
repositories {
// The Google Maven repository must be listed first
google()
maven {
url 'https://nexus.skillz.com/content/groups/public/'
}
maven {
url "https://maven.singular.net/"
}
maven {
url 'https://jitpack.io/'
}
}
}

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

2. Add 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, view the release notes. For managed accounts, please reach out to your Skillz Account Manager for guidance on which build to integrate.

Add the following in the module build.gradle file you edited earlier:

build.gradle
android {
// Extra code excluded for brevity
}

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

The newest version of the SDK can be found in Skillz's Maven Repository. When upgrading to newer Skillz SDK releases in the future, you’ll need to update the specified version within your project.

3. Set Android SDK Version Compatibility

In the build.gradle file, ensure Android SDK version compatibility. Skillz requires:

  • works best with a compileSdkVersion of 34
  • minSdkVersion of 24 or higher
  • targetSdkVersion of 34

If you want to learn more about what's the difference between compiledSdkVersion and targetSdkVersion, you can check out the official Android developer documentation.

build.gradle
android {
compileSdkVersion 34

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

You must also include the abiFilters line in order to support both 32-bit and 64-bit devices. Read more about ABIs here.

4. 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 of android.

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

Now, add a file called multidex-keep.txt to your Android Studio project in the same directory as build.gradle with the contents below:

multidex-keep.txt
-keep class com.google.firebase.crashlytics.** { *; }
-keep class timber.log.** { *; }
-keep class com.facebook.FacebookSdk
-keep class com.path.android.jobqueue.JobManager

5. Enable AndroidX and R8

The Skillz SDK depends on the AndroidX Support Libraries instead of the original Android Support Libraries. Additionally, R8 has replaced Proguard as the standard tool for code shrinking, desugaring, and obfuscation.

In your project, add the lines below to the gradle.properties file. If it does not already exist, create it. These will tell Android Studio to automatically migrate dependencies from any original Support Libraries to their AndroidX equivalents, and enable R8.

"gradle.properties
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true

6. Upgrade to Java 17

Since the SDK uses Java 17, you’ll also need to update to that version of Java to ensure compatibility. Add these lines to your module gradle.build file.

gradle.build
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
}

7. Add Proguard Rules

Skillz is pre-obfuscated and requires Proguard rules to prevent it from being re-obfuscated and shrunken. Otherwise, this will cause crashes and other problems at runtime. In your build.gradle, ensure minifyEnabled and shrinkResources are both set to false. Additionally, specify 'proguard-rules.pro' as your Proguard file.

build.gradle
android {
buildTypes {
debug {
jniDebuggable true
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

Next, add the snippet below in your Proguard file, located in the root of the current module:

proguard-rules.pro
# The Skillz Android SDK is already obfuscated, prevent it
# from being obfuscated again if minifyEnabled true
-dontobfuscate

# Prevent the Skillz SDK from being minified if minifyEnabled true
-dontshrink

-keep class bitter.jnibridge.* { *; }
-keep class com.unity3d.player.* { *; }
-keep class org.fmod.* { *; }
-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 retrofit.** {*;}
-keep class com.facebook.** {*;}
-keep class com.amazonaws.** {*;}

8. Set Skillz meta-data

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

AndroidManifest.xml
<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.MenuActivityName" />
<meta-data android:name="skillz_progression_activity" android:value="com.packagename.ProgressionActivityName" />
</application>

Edit each meta-data line to contain the correct information for your game.


skillz_game_id

<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 from the home page for the game - simply click on Games on the left navigation bar, and select the game.


skillz_production

<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.


skillz_game_activity

<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”.


skillz_allow_exit

<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.


skillz_exit_activity

<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.


skillz_progression_activity

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

Set the value to the name of the activity Skillz should launch when a user clicks a Progression Entry Point. Leave blank if this feature is not used or value is not yet known.


9. Set Main Activity Launch Mode

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.

AndroidManifest.xml
<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>

10. Extend Game Activity

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

Example:

GameActivity.java
import com.skillz.SkillzActivity;

public class GameActivity extends SkillzActivity {
// ...
}

11. Build and Run

Make sure your build.gradle syncs successfully, and that your project still compiles.

It is suggested to build and run the project to resolve any conflicts or issues prior to further Skillz implementation. Once the project has been tested, you're ready to implement the Skillz UI.