最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

kotlin - Compose Multiplatform: java.lang.IllegalStateException: Could not load font in multi-module project - Stack Overflow

programmeradmin3浏览0评论

I’m working on a multi-module Compose Multiplatform (CMP) project and created a new CMP library module using libs.plugins.multiplatform.library.

However, when I added font resources and tried to use them, I encountered this error at runtime:

java.lang.IllegalStateException: Could not load font
Caused by: java.lang.IllegalStateException: Unable to load font

What I Tried and Expected Results

  • I checked if the font files were correctly added to the resources folder. ✅
  • I confirmed that my build.gradle.kts were correctly set up. ✅

Expected Behavior: Fonts should load properly without any runtime exceptions.
Actual Behavior: The app crashes due to IllegalStateException.

Solution That Worked for Me

The issue was resolved by removing libs.plugins.multiplatform.library and using libs.plugins.android.library instead.

Fixed Module-Level build.gradle.kts

plugins {
    alias(libs.pluginspose)
    alias(libs.plugins.multiplatform)
    alias(libs.pluginsposepiler)
    alias(libs.plugins.android.library) // ✅ Fix: Use android.library instead
}

Fixed Project-Level build.gradle.kts

plugins {
    alias(libs.plugins.multiplatform) apply false
    alias(libs.plugins.multiplatform.library) apply false
    alias(libs.pluginsposepiler) apply false
    alias(libs.pluginspose) apply false
    alias(libs.plugins.android.application) apply false
    alias(libs.plugins.android.library) apply false // ✅ Added
}

Version Catalog libs.versions.toml

[plugins]
android-library = { id = "com.android.library", version.ref = "agp" }  # ✅ Added

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论