Issue
I'm looking a way to open a file in flutter. Specifically a PDF. I found everywhere: open_file but it seems to be deprecated:
The plugin `open_file` uses a deprecated version of the Android embedding. To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs. If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.
Also I have to run my app using: flutter run --no-sound-null-safety
.
And when I run it, I get an error:
- What went wrong: Execution failed for task ':app:mergeDexDebug'. A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingTaskDelegate There was a failure while executing work items > A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingWorkAction > com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: The number of method references in a .dex file cannot exceed 64K. Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
Other than that, I also tried open_document, I installed, created the create provider_paths.xml, added the AndroidManifest but I got another error.
Any suggestions? Thanks <3
Solution
For some reason when I installed the open_file package using flutter pub add open_file
, it downloaded version 2.1.1, even though in the console it said version 3.2.1 is available. This probably due to some internal dependency issues. I typed the latest version number in the pubspec.yaml file and saved and got it installed that way.
From version 3.0.0, the open_file package has updated to the v2 Android Plugin APIs,
Answered By - Tarak Parab
Answer Checked By - Terry (JavaFixing Volunteer)