Search code examples
flutterandroid-studiogradle

Error: Type 'DecoderCallback' not found. ImageStreamCompleter load(PdfPageImageProvider key, DecoderCallback decode)


After my app failed on iOS 17, I had to do a lot of upgrading, including buying a new Macbook, just so I can do a build for iOS 17. It turned out that the TextFormField in Flutter didn't work with Autocorrect in iOS 17.

So, after upgrading Macbook, XCode and Android Studio, I had a lot of packages to update as well (my app was only 2 years old). I am now using Android Studio Giraffe. Getting my app to work again because of all the updates to the packages took quite a while, but I have it all working now.

I normally develop on my Windows computer, so I copied all my changes to Windows, upgraded Android Studio to Giraffe, ran Flutter Pub Upgrade to get latest version of Flutter and Dart and attempted a build, but this is where I have stalled.

I am getting error...

/C:/Users/me/AppData/Local/Pub/Cache/hosted/pub.dev/pdfx-2.5.0/lib/src/viewer/pdf_page_image_provider.dart:24:55: Error: Type 'DecoderCallback' not found.   ImageStreamCompleter load(PdfPageImageProvider key, DecoderCallback decode) =>
                                                      ^^^^^^^^^^^^^^^ /C:/Users/me/AppData/Local/Pub/Cache/hosted/pub.dev/pdfx-2.5.0/lib/src/viewer/pdf_page_image_provider.dart:40:7: Error: Type 'DecoderCallback' not found.
      DecoderCallback decode) async {
      ^^^^^^^^^^^^^^^ /C:/Users/me/AppData/Local/Pub/Cache/hosted/pub.dev/pdfx-2.5.0/lib/src/viewer/pdf_page_image_provider.dart:24:55: Error: 'DecoderCallback' isn't a type.   ImageStreamCompleter load(PdfPageImageProvider key, DecoderCallback decode) =>
                                                      ^^^^^^^^^^^^^^^ /C:/Users/me/AppData/Local/Pub/Cache/hosted/pub.dev/pdfx-2.5.0/lib/src/viewer/pdf_page_image_provider.dart:40:7: Error: 'DecoderCallback' isn't a type.
      DecoderCallback decode) async {
      ^^^^^^^^^^^^^^^ Target kernel_snapshot failed: Exception


FAILURE: Build failed with an exception.

* Where: Script 'E:\Dev\flutter-new\packages\flutter_tools\gradle\src\main\groovy\flutter.groovy' line: 1350

* What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'E:\Dev\flutter-new\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 7s Exception: Gradle task assembleDebug failed with exit code 1

I am a bit stuck, and there is very little I can find to resolve this.

My flutter doctor is...

[√] Flutter (Channel stable, 3.16.0, on Microsoft Windows [Version 10.0.22621.2715], locale en-GB)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[√] Chrome - develop for the web
[!] Visual Studio - develop Windows apps (Visual Studio Community 2017 15.9.48)
    X Visual Studio 2019 or later is required.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its
default components
[!] Android Studio (version 2021.2)
    X Unable to determine bundled Java version.
[√] Android Studio (version 2022.3)
[√] Android Studio (version 4.2)
[√] Connected device (4 available)
[√] Network resources

! Doctor found issues in 2 categories.

I am not writing for Windows, so the reason for VS2019 is not required. I have Java version 8 installed.

When I try to upgrade Gradle using the AGP Ugrade Assistant... nothing happens.

I don't know where else to turn to find out how to get beyond this.


Solution

  • Currently, pdfx package has a problem due to flutter upgrading to version 3.16 as mentioned in this issue https://github.com/ScerIO/packages.flutter/issues/448

    There is a temporary way to fix it by changing the pdfx package inside your pubspec.yaml from pdfx: ^2.4.0 to

    pdfx: 
      git:
       url: 'https://github.com/ScerIO/packages.flutter' 
       ref: '4be9de9ffed5398fd7d5f44bbb07dcd3d3f1711b'  
       path: packages/pdfx