Flutter 无法加载Flatter pdf查看器本机库

Flutter 无法加载Flatter pdf查看器本机库,flutter,dart,pdf,pdf-generation,Flutter,Dart,Pdf,Pdf Generation,您好,所以我使用此软件包在我的应用程序pub.dev/packages/flatter\u full\u pdf\u查看器中显示pdf,并使用pdf软件包pub.dev/packages/pdf创建pdf 这是我用来创建pdf并导航到pdf查看器页面的代码: Future<Uint8List> generateInvoice( PdfPageFormat pageFormat, SalesOrder salesOrder) async { final lorem = pw

您好,所以我使用此软件包在我的应用程序pub.dev/packages/flatter\u full\u pdf\u查看器中显示pdf,并使用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 Street\nKnoxville, Tennessee(TN), 37929\n865-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)));
 }
这是我的身材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 viewer屏幕时,屏幕总是变为白色,出现以下错误:

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)

非常感谢

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

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)