dnfield / flutter_svg

SVG parsing, rendering, and widget library for Flutter
MIT License
1.68k stars 460 forks source link

Error: 'AssetBundle' isn't a type. AssetBundle? bundle, #610

Open abhilash007 opened 3 years ago

abhilash007 commented 3 years ago

../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.23.0+1/lib/svg.dart:325:5: Error: 'AssetBundle' isn't a type. AssetBundle? bundle,

daohoangson commented 3 years ago

If you are on stable channel, make sure Flutter version is at least 2.5.0. You need at least 2.4.0 pre for the latest version of this package. See #611.

AramSemerjyan commented 3 years ago

Same for me. Haven't tried it on android yet. But getting error:

../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.23.0+1/lib/svg.dart:325:5: Error: Type 'AssetBundle' not found.
        AssetBundle? bundle,
        ^^^^^^^^^^^
    ../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.23.0+1/lib/svg.dart:325:5: Error: 'AssetBundle' isn't a type.
        AssetBundle? bundle

when building on iOS.

Here is my flutter doctor -v result:

[✓] Flutter (Channel stable, 2.5.3, on macOS 11.6 20G165 darwin-x64, locale en-US)
    • Flutter version 2.5.3 at /Users/aram/Documents/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (2 weeks ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/aram/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 13.0, Build version 13A233
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.56.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
    • sdk gphone x86 arm (mobile) • emulator-5554                        • android-x86    • Android 11 (API 30) (emulator)
    • iPhone 12 Pro Max (mobile)  • 41C5B2F0-9B55-49DC-BC3A-13881C97AEE2 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
    • Chrome (web)                • chrome                               • web-javascript • Google Chrome 95.0.4638.54

! Doctor found issues in 1 category.
anglesen1120 commented 3 years ago

Same for me. Haven't tried it on android yet. But getting error:

../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.23.0+1/lib/svg.dart:325:5: Error: Type 'AssetBundle' not found.
        AssetBundle? bundle,
        ^^^^^^^^^^^
    ../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.23.0+1/lib/svg.dart:325:5: Error: 'AssetBundle' isn't a type.
        AssetBundle? bundle

when building on iOS.

Here is my flutter doctor -v result:

[✓] Flutter (Channel stable, 2.5.3, on macOS 11.6 20G165 darwin-x64, locale en-US)
    • Flutter version 2.5.3 at /Users/aram/Documents/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (2 weeks ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/aram/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 13.0, Build version 13A233
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.56.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
    • sdk gphone x86 arm (mobile) • emulator-5554                        • android-x86    • Android 11 (API 30) (emulator)
    • iPhone 12 Pro Max (mobile)  • 41C5B2F0-9B55-49DC-BC3A-13881C97AEE2 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
    • Chrome (web)                • chrome                               • web-javascript • Google Chrome 95.0.4638.54

! Doctor found issues in 1 category.

You should be try again with flutter 2.5.3! clean and run again ^^

pdsliuzhen commented 3 years ago

Same for me

cristian1980 commented 3 years ago

I had the same issue but, upgrading to 2.5.3 and restarting Android Studio, fixed it.

pdsliuzhen commented 3 years ago

my flutter version is 2.2.3 is not ok, upgrade to 2.5 is ok, but i have to use verison 2.2.3

baguskto commented 3 years ago

I use flutter version 2.2.2, and use flutter_svg version 0.22.0. its works like a charm

nizarmasri-rockspoon commented 2 years ago

Running on Flutter 2.5.3 stable, cleaned the project and restarted android studio, still getting this error

kannel-outis commented 2 years ago

is there any fix for this without upgrading flutter.... the latest flutter version keeps deleting my .gradle folder so it is not an option for me ATM .

shinayser commented 2 years ago

I'm having this project right now. Using flutter 2.2.3 and can't upgrade it to 2.8 (or 2.5) yet =(

And I dont have direct dependnecy of flutter_svg, it is coming as a transitive dependency from the flutter_html package.

dnfield commented 2 years ago

Ahh so it sounds like I missed updating a lower bound constraint on the package. That's unfortunate. I don't have a great way to fix that. If you're seeing this issue, you need to either upgrade your flutter SDK or downgrade your flutter_svg...

shinayser commented 2 years ago

I was able to fix that by placing:

dependency_overrides:
  flutter_svg: 0.22.0

on my apps's pubpec.yaml.

moradnajem commented 2 years ago

+1