当前位置: 首页 > backend >正文

解决找不到字体的问题

PlayerView在创建的时候回生成一个PlayerControlView,PlayerControlView构造方法中会用到字体。这个字体在某些机型上找不到。导致应用崩溃。

报错信息大概是这样的

 Binary XML file line #14: Error inflating class androidx.media3.ui.PlayerView

androidx.media3.ui.PlayerControlView.<init>(MyApplication:83)

androidx.media3.ui.PlayerView.<init>(MyApplication:92)

androidx.media3.ui.PlayerView.<init>(MyApplication:2)

解决方案:

把代码下载到本地,然后以库的module的方式依赖

具体操作就是先打开https://github.com/androidx/media/releases/tag/1.3.1

然后下载zip

然后到项目中找到/libraries/ui

在android studio 中File->new ->import module 选择libraries/ui

然后命名一下module的名字

然后找到PlayerControlView 在 构造方法中关于 Typeface 使用字体的逻辑都删掉

然后修改一下build.gradle

// Copyright (C) 2016 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
plugins {id 'com.android.library'  // 库模块
}
android {namespace 'androidx.media3.ui'compileSdkVersion 34defaultConfig {minSdkVersion 21targetSdkVersion 33}buildTypes {release {minifyEnabled false}}
}dependencies {implementation 'androidx.media3:media3-common:1.3.1'compileOnly 'androidx.recyclerview:recyclerview:1.3.0'compileOnly 'androidx.media:media:1.7.0'implementation 'androidx.annotation:annotation:1.3.0'compileOnly 'org.checkerframework:checker-qual:3.13.0'compileOnly 'org.jetbrains.kotlin:kotlin-annotations-jvm:1.8.20'}ext {releaseArtifactId = 'media3-ui'releaseName = 'Media3 UI module'
}

 

最后在主工程build.gradle引用一下 

implementation project(":media3_ui")

然后setting.gradle 申明一下

include(':media3_ui')
http://www.xdnf.cn/news/1288.html

相关文章:

  • org.springframework.beans.factory.config.YamlPropertiesFactoryBean 类详解
  • Java函数生成实际应用案例:数据处理流水线
  • 代理设计模式:从底层原理到源代码 详解
  • RT-Thread学习笔记(三)
  • 从零开始学java--二叉树和哈希表
  • 工作中sql总结
  • 无需复杂操作即可锁定键鼠的工具
  • [大模型]什么是function calling?
  • Linux操作系统--进程程序替换and做一个简单的shell
  • 3.6/Q1,Charls数据库经典文章解读
  • 【第九章 Python学习之函数Ⅱ】
  • 监控页面卡顿PerformanceObserver
  • idea快捷键 Project tool window
  • MySQL 性能监控工具的多维度对比分析
  • 出现了锁等待或死锁现象怎么办?乐观锁?分布式锁了解一下?
  • C语言教程(十三):C 语言中 enum(枚举)的详细介绍
  • C++ 学习指南
  • 一款强大的实时协作Markdown工具 | CodiMD 9.6K ⭐
  • 携程-酒旅-数据研发面经【附答案】
  • 【Spring】单例作用域下多次访问同一个接口
  • Discuz!+DeepSeek:传统论坛的智能化蜕变之路
  • 【C++】新手入门指南(下)
  • 《Linux TCP通信深度解析:实现高可靠工业数据传输客户端》
  • 使用Python设置excel单元格的字体(font值)
  • 笔记本电脑研发笔记:BIOS,Driver,Preloader详记
  • Win10一体机(MES电脑设置上电自动开机)
  • 《Android系统应用部署暗礁:OAT文件缺失引发的连锁崩溃与防御体系构建》
  • Mediatek Android13 设置Launcher
  • 基于ssm的疫情防控志愿者管理系统(源码+文档)
  • SpringBoot_为何需要SpringBoot?