Troubleshooting Unity

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

📘

Troubleshooting Steps

Check this page first for common issues based on Unity Setup.

For Android and/or iOS Platform issues see:

Try the example project on our Github repository.

If stuck, contact support directly or email [email protected] for help. For faster assistance, please provide:

  • What version of Unity are you using?
  • What version of the OneSignal Unity SDK are you using?
  • Do your build settings use "Custom Main Gradle Template" or not?
    Can you provide a copy of your:
  • manifest.json (located in the Packages/ folder)
  • GchProjectSettings.xml (located in the ProjectSettings/ folder)
  • AndroidResolverDependencies.xml (located in the ProjectSettings/ folder)

Unity Version Upgrade

After upgrading the Unity Version on your project, Click Window -> OneSignal and rerun all steps.

Make sure that all other configuration settings from our setup guide are correct as well, since these can change with version upgrade.


iOS framework addition failed due to a CocoaPods installation failure

You may get an error like the following in Unity:

Text version of the screenshot above:

iOS framework addition failed due to a CocoaPods installation failure. This will will likely result in an non-functional Xcode project.

After the failure, "pod repo update" was executed and succeeded. "pod install" was then attempted again, and still failed. This may be due to a broken CocoaPods installation. See: https://guides.cocoapods.org/using/troubleshooting.html for potential solutions.

pod install output:

Analyzing dependencies
[!] Unable to find host target(s) for UnityFramework, OneSignalNotificationServiceExtension. Please add the host targets for the embedded targets to the Podfile.
Certain kinds of targets require a host target. A host target is a "parent" target which embeds a "child" target. These are example types of targets that need a host target:
- Framework
- App Extension
- Watch OS 1 Extension
- Messages Extension (except when used with a Messages Application)

To resolve open from the top menu Assets > External Dependency Manager > iOS Resolver > Settings. Ensure "Always add the main target to Podfile" is checked:


Android - Library missing error

If you see a Google Play Services, Android Support, or AndroidX missing library error then the External Dependency Manager may have not have resolved dependencies.

1. Run Assets > External Dependency Manager > Android Resolver > Force Resolve from the menu bar.

2. You should now a list of files similar to the screenshot below in your Assets/Plugins/Android folder.

3. If these files do not appear check the Unity log for errors and follow the External Dependency Manager error instructions.

👍

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.


iOS MESSAGE: "Your App would like to find and connect to devices on your local network."

Unity triggers this when it's in "Development" mode when doing a build. This will not show on "Production" unless you have another iOS Library that requires it. OneSignal does not require this.


AndroidX Compatibility (only for older OneSignal 2.x.x versions)

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. Go to Assets > External Dependency Manager > Android Resolver > Settings and check the following;

  • Use Jetifier
  • Patch gradleTemplate.properties
  • Use project settings

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

3. Go to File > Build Settings... then click on the "Player Settings..." button

4. From here go to Publishing Settings and check "Custom Gradle Properties Template".


Record Unity Packaging APK Error The Option 'Android.Enabler8' Is Deprecated and Should Not Be Used Anymore.

Solution: https://www.programmersought.com/article/50008714052/


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

UnauthorizedAccessException to AndroidManifest (only for older OneSignal 2.x.x versions)

If you see this error:

UnauthorizedAccessException: Access to the path "Assets/Plugins/Android/OneSignalConfig.plugin/AndroidManifestTemplate.xml" or "Assets/Plugins/Android/OneSignalConfig.plugin/AndroidManifest.xml" is denied.
System.IO.File.Copy (System.String sourceFileName, System.String destFileName, System.Boolean overwrite) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
OneSignalEditorScriptAndroid.createOneSignalAndroidManifest () (at Assets/OneSignal/Editor/OneSignalEditorScript_Android.cs:44)
OneSignalEditorScriptInit..cctor () (at Assets/OneSignal/Editor/OneSignalEditorScriptInit.cs:9)
Rethrow as TypeInitializationException: The type initializer for 'OneSignalEditorScriptInit' threw an exception.
System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) (at <eae584ce26bc40229c1b1aa476bfa589>:0)

"Assets/Plugins/Android/OneSignalConfig.plugin/AndroidManifestTemplate.xml" must be readable.

"Assets/Plugins/Android/OneSignalConfig.plugin/AndroidManifest.xml" does not need to be checked in, this will be regenerated at build time from Unity. You will just need to make sure the folder is writable.


Android - Error calling Init

When calling init method we get the following error message:

"InvalidOperationException: Android platform is not supported by OneSignal"
at OneSignal.Init () [0x00000] in <00000000000000000000000000000000>:0

Check your app's lifecycle methods and where you are invoking OneSignal's initialization process. This is likely a concurrency issue and OneSignal is being initialized too early.


Did this page help you?