gpt4 book ai didi

android - iTextPdf : Android : Proguard issues with fonts , res/font/sfui_semibold.ttf 找不到文件或资源

转载 作者:行者123 更新时间:2023-12-05 00:02:17 25 4
gpt4 key购买 nike

在发布版本中启用 ProGuard 时,我无法制作 PDF,因此崩溃:

Caused by java.io.IOException: res/font/sfui_semibold.ttf not found as file or resource.
at com.itextpdf.text.io.RandomAccessSourceFactory.createByReadingToMemory(RandomAccessSourceFactory.java:25)
at com.itextpdf.text.io.RandomAccessSourceFactory.createBestSource(RandomAccessSourceFactory.java:66)
at com.itextpdf.text.pdf.RandomAccessFileOrArray.<init>(RandomAccessFileOrArray.java:13)
at com.itextpdf.text.pdf.TrueTypeFont.process(TrueTypeFont.java:15)
at com.itextpdf.text.pdf.TrueTypeFont.<init>(TrueTypeFont.java:182)
at com.itextpdf.text.pdf.BaseFont.createFont(BaseFont.java:214)
at com.itextpdf.text.pdf.BaseFont.createFont(BaseFont.java:8)
at com.itextpdf.text.pdf.BaseFont.createFont(BaseFont.java:7)
at in.swipe.app.app.ui.utils.invoice_templates.InvoiceTemplate.getSemiBoldFont(InvoiceTemplate.java:10)
at in.swipe.app.app.ui.utils.invoice_templates.InvoiceTemplate.initInvoiceHeader(InvoiceTemplate.java:11)
at in.swipe.app.app.ui.utils.invoice_templates.TemplateBuilder.generateInvoiceTemplate(TemplateBuilder.java:43)
at in.swipe.app.app.ui.utils.invoice_templates.TemplateBuilder.generateInvoiceTemplate$default(TemplateBuilder.java:3)
at in.swipe.app.app.ui.invoice.details.InvoiceDetailsFragment.viewBill(InvoiceDetailsFragment.java:3)
at in.swipe.app.app.ui.invoice.details.InvoiceDetailsFragment.requestPermissionViewBillLauncher$lambda-13(InvoiceDetailsFragment.java:3)
at in.swipe.app.app.ui.invoice.details.InvoiceDetailsFragment$$InternalSyntheticLambda$0$15aa358d09d613429d28053a6b32a207c72d2528ec90baa1ce8f449e3bd9d3db$0.onActivityResult$bridge(InvoiceDetailsFragment.java:3)
at androidx.activity.result.ActivityResultRegistry.doDispatch(ActivityResultRegistry.java:1)
at androidx.activity.ComponentActivity.onRequestPermissionsResult(ComponentActivity.java:20)
at androidx.fragment.app.FragmentActivity.onRequestPermissionsResult(FragmentActivity.java:5)
at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:8675)
at android.app.Activity.dispatchActivityResult(Activity.java:8519)
at android.app.ActivityThread.deliverResults(ActivityThread.java:5139)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:5187)
at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2135)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:236)
at android.app.ActivityThread.main(ActivityThread.java:8037)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
我认为字体文件被混淆了,这就是为什么 iTextPdf 无法找到它,所以有人有解决方案吗?某种方式来获取对 ttf 文件或 proguard 规则的引用以不混淆字体文件。

最佳答案

我想你可以试试keep规则告诉 proguard 不要混淆你的图书馆。
只需将此添加到您的 proguard-rules.pro文件:

-keep <LIBRARY_PACKAGE_NAME>
如果您不确定要使用哪个保留规则,可以在此处阅读更多信息:
https://jebware.com/blog/?p=418#:~:text=%2Dkeep%20disables%20all%20of%20ProGuard's,rename%20unused%20classes%2C%20for%20example .

关于android - iTextPdf : Android : Proguard issues with fonts , res/font/sfui_semibold.ttf 找不到文件或资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70540274/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com