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

Cordova构建应用报错:找不到android:font等FontFamilyFont属性

Fixing Cordova Android Build Errors: "Unable to find attribute android:font/fontStyle/fontWeight in FontFamilyFont"

Hey there, I’ve dealt with this exact headache when building Cordova Android apps before—those FontFamilyFont attribute errors almost always stem from mismatched Android SDK versions or outdated Cordova platform/plugin configurations. Let’s break down the proven fixes that got me back on track:

1. Update Your Cordova Android Platform

The android:font, android:fontStyle, and android:fontWeight attributes were introduced in Android API 26 (Android 8.0). If your Cordova Android platform is too old, it won’t recognize these attributes.

  • First, check your current platform version:
    cordova platform ls
    
  • If you’re running a version older than cordova-android@8.0.0 (the first version supporting API 26), update to the latest stable release:
    cordova platform remove android
    cordova platform add android@latest
    
  • You can also specify a specific compatible version (e.g., cordova-android@11.0.0) if your project has dependencies that require it.

2. Align Your Android SDK Versions

Make sure your project targets a sufficiently high Android SDK version. Instead of editing the auto-generated build.gradle directly (Cordova might overwrite it), configure this via config.xml:

  • Open your project’s config.xml, find the <platform name="android"> section, and add these preferences:
    <preference name="android-compileSdkVersion" value="33" />
    <preference name="android-targetSdkVersion" value="33" />
    
    Use the latest stable SDK version (you can check Android’s official docs for current recommendations).

3. Clean Up Build Caches

Stale build files often cause weird, unexplained errors. Wipe the cache and rebuild:

cordova clean android
rm -rf platforms/android/build
rm -rf platforms/android/app/build
cordova build android

4. Update or Troubleshoot Plugins

Outdated third-party plugins might rely on old Android SDK versions, creating conflicts:

  • List all installed plugins to check for updates:
    cordova plugin ls
    
  • Update individual plugins to their latest versions:
    cordova plugin update <plugin-name>
    
  • If a specific plugin seems to be the culprit, try removing and re-adding it:
    cordova plugin remove <plugin-name>
    cordova plugin add <plugin-name>@latest
    

These steps should resolve the FontFamilyFont attribute errors for most cases. If you’re still stuck, double-check that you have the required SDK versions and build tools installed in your Android SDK Manager.

内容的提问来源于stack exchange,提问作者George Stoilov

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.29 08:59:22