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

Android编译原生代码报错UnsatisfiedLinkError:JNI函数实现未找到

问题:AndroidPdfViewer原项目JNI链接失败(UnsatisfiedLinkError)

我fork了AndroidPdfViewer项目,计划将其底层依赖从PdfiumAndroid替换为android-pdfium。但在Android Studio中加载未做任何修改的原项目时,就出现了运行失败的问题:

PdfiumAndroid的JNI代码中定义了Java层已声明的函数,但链接器无法将C++中的函数定义与Java中的声明关联,报错日志如下:

E/barteksc.sample: No implementation found for long com.shockwave.pdfium.PdfiumCore.nativeOpenDocument(int, java.lang.String) (tried Java_com_shockwave_pdfium_PdfiumCore_nativeOpenDocument and Java_com_shockwave_pdfium_PdfiumCore_nativeOpenDocument__ILjava_lang_String_2)
E/PDFView: load pdf error
    java.lang.UnsatisfiedLinkError: No implementation found for long com.shockwave.pdfium.PdfiumCore.nativeOpenDocument(int, java.lang.String) (tried Java_com_shockwave_pdfium_PdfiumCore_nativeOpenDocument and Java_com_shockwave_pdfium_PdfiumCore_nativeOpenDocument__ILjava_lang_String_2)
        at com.shockwave.pdfium.PdfiumCore.nativeOpenDocument(Native Method)
        at com.shockwave.pdfium.PdfiumCore.newDocument(PdfiumCore.java:135)

原项目中PdfiumAndroid的gradle文件看起来存在内容缺失,我尝试在proguard-rules.pro中添加如下规则:

-keep class com.shockwave.** { *; }

该操作消除了第一条错误,但第二条UnsatisfiedLinkError仍然存在。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.22 04:06:20