OneSignal Help & Documentation

Welcome to the OneSignal New IA developer hub. You'll find comprehensive guides and documentation to help you start working with OneSignal New IA as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    Discussions

Troubleshooting Unity

Common setup and troubleshooting issues with Unity iOS, Android (and derivatives like Amazon).

Google Play Services Library missing

Android, Amazon

1. Run Assets > Play Services Resolver > Android Resolver > Force Resolve from the menu bar.

2. You should now see the following .aar and .jar files in your Assets/Plugins/Android folder.

3. If these files do not appear check the Unity log for errors and follow the JarResolover error instructions below.

👍

Done! Please check the other sections below if you still see an error. If the problem persists, send your console log, Unity version, and other plugins in your project to OneSignal. support.


Android Build Error: android:keyboardNavigationCluster OR android:font

You will get the following error in Unity if you are NOT using the latest Android target.

CommandInvokationFailure: Gradle build failed. 
/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/java
   -classpath "/Applications/Unity/PlaybackEngines/AndroidPlayer/Tools/gradle/lib/gradle-launcher-4.0.1.jar"
   org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx2048m"
   "assembleRelease"
stderr[
   UnityProjectDir/Temp/gradleOut/build/intermediates/res/merged/release/values-v26/values-v26.xml:15:21-54:
      AAPT: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.    
   UnityProjectDir/Temp/gradleOut/build/intermediates/res/merged/release/values-v26/values-v26.xml:15:
      error: Error: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
OR
CommandInvokationFailure: Gradle build failed. 
/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/java -classpath "/Applications/Unity/PlaybackEngines/AndroidPlayer/Tools/gradle/lib/gradle-launcher-4.0.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx2048m" "assembleRelease"

stderr[
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:font
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontStyle
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontWeight

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processReleaseResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt
  1. Updated to Unity 2017
  • Tested with Unity 2017.4.0f1, might work on older versions
  1. Update Android SDK
  • Platform-Tools 27+
  • Build Tools 27+ (Without 28.0.0-rc1)
  1. File > Build Settings.. > Player Settings... > Target API Level
  • Set as Automatic (highest installed)

This is an issue with the Unity Jar Resolver, more details in on issue 111.


"No resource found that matches the given name" build errors

Android, Amazon

You may receive errors like the following if your project's path is to long.

C:\full\path\to\project\Temp\StagingArea\android-libraries\play-services-base-9.4.0\res\drawable\common_google_signin_btn_text_light.xml:12: error:
Error: No resource found that matches the given name (at 'drawable' with value '@drawable/common_google_signin_btn_text_light_normal').

Close Unity and move your project to the root of your drive. Then open the new location in Unity and build again.


Xcode - Undefined symbols for architecture xxxx - OneSignal

iOS
  1. If you are seeing the following error then the OneSignal library was not correctly enabled for iOS builds.

    ```Undefined symbols for architecture arm64: "_OBJC_CLASS_$_OneSignal", referenced from: objc-class-ref in OneSignalUnityRuntime.o ld: symbol(s) not found for architecture arm64```

  2. Make sure `iOS` is checked on `Assets/OneSignal/Platforms/iOS/libOneSignal` under the inspector view.

  3. Rebuild from Unity then rebuild in Xcode.


Android - Too many field references to fit in one dex file

trouble writing output: Too many field references to fit in one dex file: 71720; max is 65536.
You may try using multi-dex. If multi-dex is enabled then the list of classes for the main dex list is too large.

This means there are too many Java methods in all the libraries (and it's decencies) to build the app.

We recommend switching to the new Gradle "Build System" introduced in Unity 2017.2 to resolve this issue. This is under File > Build Settings > Build System and select Gradle.

If this does not solve the issue you can try these additional options.


Build error with Facebook SDK

Android

Make sure you have the latest Facebook SDK version. Version 7.11.1 or newer is required
https://developers.facebook.com/docs/unity

com/google/firebase/messaging/cpp/RegistrationIntentService not found

Android

Update to Firebase 5.3.1 (Released Oct. 3 2018)
https://firebase.google.com/docs/unity/setup


AndroidX Compatibility

🚧

Only follow the below instructions if you're using Unity 2018.4 or newer

If you have any Plugins in your Unity project that are using AndroidX please follow these steps.
An example of some Plugins that include AndroidX are; GoogleMobileAds 3.17.0+, AdMob 4.12

Please follow these steps if you are seeing errors like this when building;

Execution failed for task ':checkDebugDuplicateClasses'.
java.lang.RuntimeException: java.lang.RuntimeException: Duplicate class android.support.customtabs.ICustomTabsCallback found in modules classes.jar (:androidx.browser.browser-1.0.0:) and classes.jar (:com.android.support.customtabs-27.1.1:)

1. Ensure you are using Unity 2018.4 or newer.

2. Go to Assets > Play Services Resolver > Android Resolver > Settings and check the following;

  • Patch main Template.gradle
  • Use jetifier
  • Use project settings

3. Scroll down and press "OK" to save these settings.

4. Depending on your Unity version follow one of the sections below:

Unity 2019.3 Or Newer

5A. Create a new file named Assets/Plugins/Android/settingsTemplate.gradle with the following contents.

// This file contents should be placed at Assets/Plugins/Android/settingsTemplate.gradle
// This works around Unity's 2019.3 bug where their root build.gradle is placing buildscript under allprojects
// On it's own it doesn't create issues however doing so means including a buildscript block in any sub projects
//   such as "unityLibrary" which is generated from the template Assets/Plugins/Android/mainTemplate.gradle does not work.
// It results in a build error of "Configuration with name 'compileClasspath' not found." on a lint task.
// Normally adding "lintOptions { abortOnError false }" bypasses any lint task errors however
//   either due to a bug with the Android Gradle plugin or an order of operations this does seem to be applying in this case.
// Until Unity fixes their root build.gradle we will need to keep using this file to enable any additional Gradle plugins.

static void enableJetifier(Project project) {
    project.ext['android.useAndroidX'] = true
    project.ext['android.enableJetifier'] = true
}

static void addBuildscript(Project project) {
    project.buildscript {
        repositories {
            maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
        }
        dependencies {
            // OneSignal-Gradle-Plugin
            classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.7, 0.99.99]'
        }
    }
}

static void applyPlugins(Project project) {
    // Only apply OneSignal-Gradle-Plugin to the :app project. (Unity calls this :launcher)
    if (project.name != 'launcher')
        return

    project.afterEvaluate {
        it.apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
    }
}

gradle.rootProject {
    it.afterEvaluate {
        it.allprojects {
            // Since Unity 2019.3 enabling Jetifier via mainTemplate.gradle is no longer working
            // Enabling it for all gradle projects here.
            enableJetifier(it)

            addBuildscript(it)
            applyPlugins(it)
        }
    }
}


// Per Unity's docs /*/*INCLUDES/*/* should be at the bottom.
// https://docs.unity3d.com/Manual/android-gradle-overview.html

// However it seem to have left out this include line
include ':launcher', ':unityLibrary'
**INCLUDES**

Unity 2019.2 Or Older

5B.1 Go to File > Build Settings... then click on the "Player Settings..." button

5B.2 From here go to Publishing Settings and check "Custom Gradle Template". Take note of the gradle file path.

5B.3 Open the file mainTemplate.gradle, remove the comment
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN

5B.4 Add the following to the very top of the file

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/'}
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.7, 0.99.99]'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

repositories {
    maven { url 'https://maven.google.com' }
}

UnityPlayerActivity

Some users reported crashes when notification is received and clicked using Unity 2019.3.5f1 and extended UnityPlayerActivity.

Adding this to your AndroidManifest.xml fixed the issue reported:

<meta-data android:name="unityplayer.UnityActivity" android:value="true" />

Updated 2 months ago



Troubleshooting Unity


Common setup and troubleshooting issues with Unity iOS, Android (and derivatives like Amazon).

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.