Search code examples
flutterandroid-studiogoogle-fonts

I encounter an error after a flutter update. AssetManifest imported from two libraries


I have an app that I created a year ago that worked great. Lately I opened my code and Flutter suggested I do an update. After the update it no longer works. the error encountered indicates that I imported AssetManifest from 'package:flutter/src/services/asset_manifest.dart' and from 'package:google_fonts/src/asset_manifest.dart'.

Launching lib/main.dart on AOSP on IA Emulator in debug mode... Running Gradle task 'assembleDebug'... ../../.pub-cache/hosted/pub.dev/google_fonts-3.0.1/lib/src/google_fonts_base.dart:14:1: Error: 'AssetManifest' is imported from both 'package:flutter/src/services/asset_manifest.dart' and 'package:google_fonts/src/asset_manifest.dart'. import 'asset_manifest.dart'; ^^^^^^^^^^^^^ ../../.pub-cache/hosted/pub.dev/google_fonts-3.0.1/lib/src/google_fonts_base.dart:34:31: Error: 'AssetManifest' is imported from both 'package:flutter/src/services/asset_manifest.dart' and 'package:google_fonts/src/asset_manifest.dart'. AssetManifest assetManifest = AssetManifest(); ^^^^^^^^^^^^^ Target kernel_snapshot failed: Exception

FAILURE: Build failed with an exception.

  • Where: Script '/Users/innot/Developer/flutter/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy' line: 1214

  • What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'.

Process 'command '/Users/innot/Developer/flutter/bin/flutter'' 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


Solution

  • As mentioned here, version 4.0.1 of the google_fonts fixes this issue. Therefore, upgrading to at least version 4.0.1 should resolve your problem.