flutter_svg icon indicating copy to clipboard operation
flutter_svg copied to clipboard

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

Open abhilash007 opened this issue 3 years ago • 13 comments

../../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,

abhilash007 avatar Oct 19 '21 16:10 abhilash007

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.

daohoangson avatar Oct 19 '21 17:10 daohoangson

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.

AramSemerjyan avatar Nov 01 '21 19:11 AramSemerjyan

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 ^^

anglesen1120 avatar Nov 04 '21 20:11 anglesen1120

Same for me

pdsliuzhen avatar Nov 08 '21 03:11 pdsliuzhen

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

cristian1980 avatar Nov 10 '21 15:11 cristian1980

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

pdsliuzhen avatar Nov 15 '21 09:11 pdsliuzhen

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

baguskto avatar Nov 20 '21 08:11 baguskto

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

nizarmasri-rockspoon avatar Dec 07 '21 13:12 nizarmasri-rockspoon

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 .

kannel-outis avatar Dec 07 '21 15:12 kannel-outis

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.

shinayser avatar Jan 19 '22 19:01 shinayser

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...

dnfield avatar Jan 19 '22 23:01 dnfield

I was able to fix that by placing:

dependency_overrides:
  flutter_svg: 0.22.0

on my apps's pubpec.yaml.

shinayser avatar Jan 20 '22 13:01 shinayser

+1

moradnajem avatar Feb 25 '22 08:02 moradnajem