Building to Mobile - Unity
- iOS
- Android
This article will walk you through building your Skillz Unity project to Android and iOS.
1. Configure Game for Skillz​
Select the Skillz > Settings
menu item to bring up the Skillz Settings window:
Set your Game ID
, the environment (Sandbox
or Production
), and the orientation for your game.
Select environment Sandbox
for development and testing. Come back here and switch to Production
when readying the build for publishing to the app stores.
Please ensure to select the correct orientation if you plan to distribute your game on Android. This setting is important for ensuring your game renders in the correct orientation for gameplay. For instance, if the scene for your main menu is designed for Portrait mode, but your game scene is designed for Landscape, the orientation setting should be set to Landscape.
Additionally, you can choose if users are allowed to exit the Skillz UI via its sidebar menu.
2. Resolve Dependencies​
- iOS
- Android
Configure External Dependency Manager​
Skillz for Unity is bundled with the External Dependency Manager plugin. This plugin will resolve transitive dependencies between multiple libraries for iOS. Preliminary configuration is needed:
- Select the
Assets > External Dependency Manager > iOS Resolver > Settings
menu item. - Click the
Reset to Defaults
button as a precaution. - Click the
OK
button to save your changes.
Install CocoaPods​
The External Dependency Manager can install CocoaPods for you, if it is not already installed:
- Select
Assets > External Dependency Manager > iOS Resolver > Install CocoaPods
- Click
OK
in the pop-up confirming installation was successful.
If the installation fails see known issue: CocoaPods Installation Fails.
Configure External Dependency Manager​
Skillz for Unity is bundled with the External Dependency Manager plugin. This plugin will resolve transitive dependencies between multiple libraries (that support it) for Android, such as Skillz and Firebase. However, preliminary configuration is needed:
- Select the
Assets > External Dependency Manager > Android Resolver > Settings
menu item. - Click the
Reset to Defaults
button as a precaution. - Uncheck the
Enable Auto-Resolution
option. - Make sure the "Patch mainTemplate.gradle" option is checked.
- By selecting this option, the External Dependency Manager will modify
Assets/Plugins/Android/mainTemplate.gradle
with the list of resolved dependencies. - The final
build.gradle
file in an exported Android Studio project will list these dependencies. - This approach is recommended by Google. Otherwise, the plugin will download the resolved dependencies as JARs/AARs.
- By selecting this option, the External Dependency Manager will modify
- Check the
Use Jetifier
option. Skillz requires the new AndroidX Support Libraries, instead of the original Android Support Libraries. Checking the Jetifier option ensures that all libraries that depend on the original Android Support Libraries are migrated to the equivalent AndroidX ones. - Click the
OK
button to save your changes.
Resolve Android Dependencies​
With the External Dependency Manager configured, it's time to resolve your Unity project's Android dependencies. Select Assets > External Dependency Manager > Android Resolver > Resolve
. A message box will display after resolution has completed.
Afterwards, verify that mainTemplate.gradle
was modified to ensure that all resolved dependencies are listed.
The dependencies section should look similar to this snippet before modification:
dependencies {
implementation ("com.skillz.sdk:skillz-sdk-android:<sdk_version_string>")
{
transitive = false
}
**DEPS**
}
And it should look similar to this snippet after modification:
dependencies {
implementation ("com.skillz.sdk:skillz-sdk-android:<sdk_version_string>")
{
transitive = false
}
// Android Resolver Dependencies Start
implementation 'androidx.appcompat:appcompat:1.3.1' // Assets/Skillz/Editor/SkillzDependencies.xml:14
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' // Assets/Skillz/Editor/SkillzDependencies.xml:36
// Etc...
If the file did not appear to be changed, you may have to save your project, reopen it, and select the Assets > External Dependency Manager > Android Resolver > Force Resolve
menu item.
3. Build and Run​
Unity Player Configuration​
- iOS
- Android
Select
Player
from the sidebar and click on theiOS
tab.Under
Settings for iOS
, expandResolution and Presentation
:- Select `Resolution Scaling Mode: Fixed DPI`
- Set `Target DPI` to `328`Under
Settings for iOS
, expandOther Settings
:- Deselect `Metal Write-Only Backbuffer`
- Deselect `Allow downloads over HTTP (nonsecure)`
Close the window. It will automatically save your new settings.
In Unity select
File > Build Settings...
.In the lower left click
Player Settings...
.Select
Player
from the sidebar and click on theAndroid
tab.Under
Settings for Android
, expandResolution and Presentation
:- Select `Resolution Scaling Mode: Fixed DPI`
- Set `Target DPI` to `328`Select
Player
from the left navigation and expandOther Settings
:- Select `Scripting Backend: IL2CPP`
- Under `Target Architectures` check `ARMv7` and `ARM64` to ensure support for 32-bit and 64-bit Android devicesClose the window. It will automatically save your new settings.
Initiate Build​
- iOS
- Android
- In Unity select
File > Build Settings...
- If Platform selection is not
iOS
, selectiOS
and clickSwitch Platform
. - Click Build to initiate the build process.
- When Prompted, enter a destination to save the XCode project.
- When complete, the project can be opened by double-clicking the
*.xcworkspace
file. Do not open the project using the*.xcodeproj
file, as it will not properly initialize the CocoaPod dependencies. - In Xocde, choose a profile for your project, connect an iOS device, then run your project.
if a *.xcworkspace
file does not appear, make sure you have CocoaPods installed. If this issue persists, try the workaround in the known Issues Page.
- In Unity select
File > Build Settings...
. - If Platform selection is not
Android
, selectAndroid
and clickSwitch Platform
.
- Unity
- Android Studio
Versions 2024.x of the SDK require Gradle 7.4+, and Java 17 while Unity versions < 2022.3 come with Gradle 6.1.1, and Java JDK 8. If you wish to build the APK from Unity directly, you will need to update these dependencies first.
Update Gradle​
- Install Gradle manually following these instructions
- Go To
Unity > Preferences > External Tools
, uncheckGradle Installed with Unity
and setGradle
to the location of the Gradle version you just installed.
Update Java Development Kit (JDK)​
When building to an APK, the JDK version used for the Gradle build will be set to the one used by Unity. This version can be found under Unity
> Preferences
> External Tools
> Android
> JDK Installed with Unity
. If you try to update the JDK here, Unity will give you an error message. This is because Unity versions < 2022.3 only support JDK 1.8. Therefore we will need to leave this version as 1.8 and direct Gradle to build with another JDK.
Go to
File
>Build Settings
>Player
>Android
>Publishing Settings
then select theCustom Gradle Properties Template
option if not selected.This will create a custom gradleTemplate file under
/Assets/Plugins/Android
. It should look similar to the file below. If it does not, please rerun the Android Resolver.```csharp title="Assets/Plugins/Android/gradleTemplate.properties"
org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
org.gradle.parallel=true
android.enableR8=**MINIFY_WITH_R_EIGHT**
unityStreamingAssets=**STREAMING_ASSETS**
# Android Resolver Properties Start
android.useAndroidX=true
android.enableJetifier=true
# Android Resolver Properties End
**ADDITIONAL_PROPERTIES**
```Download Java JDK 17. You can install it with Android Studio at
Preferences
>Build, Execution, Deployment
>Build Tools
>Gradle
>Gradle JDK
>Download JDK
or download it online. https://jdk.java.net/archive/ is one of the many places you can find it.Edit the gradleTemplate file.
- Add this line to the file:
Assets/Plugins/Android/gradleTemplate.propertiesorg.gradle.java.home=<Path_To_JDK_Download>/jdk-17.jdk/Contents/Home
- For Android Studio on Mac the path is
/Applications/Android Studio.app/Contents/jbr/Contents/Home
noteFor Windows you will need to reverse the slashes in the path name so
C:\Program Files\Java\...
will becomeC:/Program Files/Java/...
Click
Build
to initiate the build process.When prompted, enter a destination to save the APK.
Check
Export Project
Click
Export
to initiate the build process.When prompted, enter a destination to save the Android Studio project.
When complete, open the project in Android Studio.
Android will prompt you to update your Gradle version. Click
Change Gradle version in Gradle wrapper to ...
If you have the wrong JDK set, it will prompt you to download and update it.
- In Android Studio, connect an Android device, then run your Android Studio project.
Firebase​
If you plan on adding Firebase to your Unity project, we recommend you use Unity Firebase 11.8.0, as it has been tested with the Skillz SDK.