flutter pdf查看器本机库加载失败



你好,所以我使用这个包来显示pdf在我的应用程序pub.dev/packages/flutter_full_pdf_viewer和pdf包pub.dev/packages/pdf创建pdf。

这是我用来创建pdf并导航到pdf查看器页面的代码:

Future<Uint8List> generateInvoice(
PdfPageFormat pageFormat, SalesOrder salesOrder) async {
final lorem = pw.LoremText();
final invoice = Invoice(
salesOrder: salesOrder,
orders: salesOrder.listOrder.where((e)=>e.status==0).toList(),
paymentInfo:
'4509 Wiseman StreetnKnoxville, Tennessee(TN), 37929n865-372-0425',
baseColor: PdfColors.blueGrey800,
accentColor: PdfColors.blueAccent700,
);
return await invoice.buildPdf(pageFormat);
}
createInvoice(SalesOrder salesOrder) async {
var a = await DownloadsPathProvider.downloadsDirectory;
print("path  = "+a.path);
final String dir = "/storage/emulated/0/Download";
final String path = '$dir/example.pdf';
final File file = File(path);
Uint8List invoice = await ig.generateInvoice(PdfPageFormat.a4, salesOrder);
await file.writeAsBytes(invoice);
Navigator.of(context)
.push(MaterialPageRoute(builder: (context) => PdfScreen(path: path)));
}

这是我的pdf浏览器屏幕

class PdfScreen extends StatelessWidget {
final String path;
PdfScreen({this.path});
@override
Widget build(BuildContext context) {
print(path);
return PDFViewerScaffold(path: path);
}
}

这是我的构建gradle:

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "com.example.test"
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}

buildTypes {
release {
signingConfig signingConfigs.debug
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
ndk {
abiFilters 'armeabi-v7a'
}
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:multidex:1.0.3'
}

它工作得很好,但在应用程序中做了很多改变后,每当我打开PDF查看器屏幕总是变白,这个错误出现:

E/com.shockwave.pdfium.PdfiumCore(32664): Native libraries failed to load - java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.test-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.test-2/lib/arm64, /data/app/com.example.test-2/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]] couldn't find "libmodpng.so"
E/art     (32664): 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 (32664): load pdf error
E/PDFView (32664): 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)

Thankyou so much

我不确定为什么会发生这种情况,但我通过清理颤振项目来解决这个问题。谢谢

相关内容

  • 没有找到相关文章

最新更新