You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Unity中使用One Signal/Pushwoosh推送插件时Gradle构建失败求助

Fixing Gradle Build Error with OneSignal & Pushwoosh in Unity

Hey there, let's work through this Gradle build failure you're hitting when using OneSignal and Pushwoosh push notification plugins in Unity. That android:font attribute error in FontFamilyFont is usually linked to mismatched Android tooling versions or plugin dependency conflicts—here are actionable steps to resolve it:

Step 1: Update Android SDK Build Tools

The android:font attribute was introduced in Android 8.0 (API level 26), so older Build Tools versions won't recognize it.

  • Open Unity Editor → Go to Edit > Project Settings > Player
  • Switch to the Android tab, scroll to Publishing Settings
  • Under Build Tools Version, select a version 26.0.0 or higher (e.g., 28.0.3 or the latest compatible version)

Step 2: Upgrade Gradle Version

Unity's default Gradle version might be too old to support newer Android attributes.

  • In the same Android Player settings, scroll to the Gradle section
  • Set Gradle Version to 5.6.4 or higher (6.x versions work well too, just ensure compatibility with your chosen Build Tools)
  • Alternatively, manually edit the gradle-wrapper.properties file in your project's Assets/Plugins/Android folder, update the distributionUrl to a recent Gradle release:
    distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
    

Step 3: Resolve Plugin Dependency Conflicts

OneSignal and Pushwoosh might be pulling in conflicting Android support libraries or font-related dependencies:

  • Navigate to Assets/Plugins/Android and check for duplicate .jar or .aar files (especially those related to AndroidX or support libraries) — delete any duplicates
  • Test building with only OneSignal enabled first, then only Pushwoosh. If one works alone, the issue is a dependency conflict between the two. You'll need to align their dependency versions (check each plugin's documentation for recommended Android library versions)

Step 4: Fix Custom Font Family Configs

If you have custom font XML files in res/font (added either manually or by plugins):

  • Ensure you're using the correct attribute for your min SDK version:
    • For API 26+, android:font is valid
    • For lower API levels, use app:font instead (requires the AndroidX AppCompat library)
  • Double-check that your project's Minimum API Level (in Player Settings) matches the attributes you're using

Step 5: Clear Caches

Stale caches often cause weird build issues:

  • In Unity, go to File > Build Settings > Android and click Clean Build Folder
  • Manually delete the Gradle cache folder at C:\Users\[YourUsername]\.gradle\caches, then restart Unity and rebuild

Your Original Error Log:

CommandInvokationFailure: Gradle build failed.
C:/Program Files (x86)/Java/jdk1.8.0_77\bin\java.exe -classpath "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.0.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx1024m" "assembleRelease"
stderr[ ERROR: In FontFamilyFont, unable to find attribute android:font ERROR: In FontFamilyFont, unable to fin...

内容的提问来源于stack exchange,提问作者Junaid Pathan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 08:12:38