Troubleshooting Unity
Common setup and troubleshooting issues with Unity iOS, Android (and derivatives like Amazon).
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.
AndroidX Compatibility
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
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.
Updated over 1 year ago