Вот код, который я использую Я использую для сохранения и открытия PDF-файла:
Код: Выделить всё
openFile() async {
String storeNameForInvoice = '${storeName.value} - $date';
final invoicesPath = await getTargetDirectoryPath();
final file = File("$invoicesPath/$storeNameForInvoice.pdf");
await file.writeAsBytes(await pdf.save());
await saveInvoiceToFirestore();
loadInvoicesToCurrentInvoice(storeName.value);
await OpenFile.open(file.path);
}
Версия Gradle
В gradle-wrapper.properties:
Код: Выделить всё
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
В build.gradle (уровень приложения):
Код: Выделить всё
compileSdk = 34
targetSdk = 34
Вот моя настройка settings.gradle:
Код: Выделить всё
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "com.google.gms.google-services" version "4.3.15" apply false
id "org.jetbrains.kotlin.android" version "1.9.0" apply false
}
include ":app"
В консоли отображается следующая ошибка:
Код: Выделить всё
C:\Users\MQ\AppData\Local\Pub\Cache\hosted\pub.dev\open_file_plus-3.4.1+1\android\src\main\java\com\joutvhu\openfile\OpenFilePlusPlugin.java:66: error: cannot find symbol
public static void registerWith(PluginRegistry.Registrar registrar) {
^
symbol: class Registrar
location: interface PluginRegistry
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':open_file_plus:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
> Run with --info option to get more log output.
> Run with --scan to get full insights.
BUILD FAILED in 1m 20s
Error: Gradle task assembleDebug failed with exit code 1
Я попробовал несколько шагов, чтобы решить эту проблему, в том числе:Выполнение обновления Flutter
Выполнение очистки Flutter
Выполнение обновления Flutter pub
Проверка устаревших пакетов с помощью flutter pub outdated
Несмотря на эти попытки, проблема остается. Кроме того, я протестировал другие библиотеки, такие как open_file,
Код: Выделить всё
url_launcher
Вопрос:
Что может быть причиной ошибки PluginRegistry.Registrar и как я могу решить эту проблему, чтобы успешно открывать PDF-файлы в моем приложении Flutter?
Подробнее здесь: https://stackoverflow.com/questions/791 ... not-find-s