flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
166.19k stars 27.49k forks source link

Assets Manifest #120882

Closed quickcodes closed 1 year ago

quickcodes commented 1 year ago

First I am getting this error


Launching lib\main.dart on SM J600G in debug mode...
: Error: 'ModalBottomSheetRoute' is imported from both 'package:flutter/src/material/bottom_sheet.dart' and 'package:modal_bottom_sheet/src/bottom_sheet_route.dart'.
import '../modal_bottom_sheet.dart';
^^^^^^^^^^^^^^^^^^^^^

: Error: The method 'File.create' has fewer named arguments than those of overridden method 'File.create'.
  Future<File> create({bool recursive = false});
               ^
org-dartlang-sdk:///third_party/dart/sdk/lib/io/file.dart:232:16: Context: This is the overridden method ('create').
  Future<File> create({bool recursive = false, bool exclusive = false});
               ^
: Error: The method 'File.create' doesn't have the named parameter 'exclusive' of overridden method 'File.create'.
  Future<File> create({bool recursive = false});
               ^
org-dartlang-sdk:///third_party/dart/sdk/lib/io/file.dart:232:16: Context: This is the overridden method ('create').

  Future<File> create({bool recursive = false, bool exclusive = false});
               ^
: Error: The method 'ForwardingFile.createSync' has fewer named arguments than those of overridden method 'File.createSync'.
  void createSync({bool recursive = false}) =>
       ^
org-dartlang-sdk:///third_party/dart/sdk/lib/io/file.dart:248:8: Context: This is the overridden method ('createSync').
  void createSync({bool recursive = false, bool exclusive = false});
       ^

: Error: The method 'ForwardingFile.createSync' doesn't have the named parameter 'exclusive' of overridden method 'File.createSync'.
  void createSync({bool recursive = false}) =>
       ^

org-dartlang-sdk:///third_party/dart/sdk/lib/io/file.dart:248:8: Context: This is the overridden method ('createSync').
  void createSync({bool recursive = false, bool exclusive = false});

       ^
: Error: The getter 'StrokeAlign' isn't defined for the class '_WebLandingSearchSectionState'.
- '_WebLandingSearchSectionState' is from 'package:demandium/feature/web_landing/widget/web_landing_search_box.dart' ('lib/feature/web_landing/widget/web_landing_search_box.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'StrokeAlign'.
                                                  strokeAlign: StrokeAlign.inside,
                                                               ^^^^^^^^^^^
: Error: 'ModalBottomSheetRoute' is imported from both 'package:flutter/src/material/bottom_sheet.dart' and 'package:modal_bottom_sheet/src/bottom_sheet_route.dart'.
      .push(ModalBottomSheetRoute<T>(
            ^^^^^^^^^^^^^^^^^^^^^
: Error: A value of type 'Object?' can't be returned from an async function with return type 'Future<T?>'.

 - 'Object' is from 'dart:core'.
 - 'Future' is from 'dart:async'.
  return result;
         ^
: Error: 'ModalBottomSheetRoute' is imported from both 'package:flutter/src/material/bottom_sheet.dart' and 'package:modal_bottom_sheet/src/bottom_sheet_route.dart'.
      .push(ModalBottomSheetRoute<T>(
            ^^^^^^^^^^^^^^^^^^^^^
: Error: A value of type 'Object?' can't be returned from an async function with return type 'Future<T?>'.

 - 'Object' is from 'dart:core'.
 - 'Future' is from 'dart:async'.
  return result;

         ^
: Error: The superclass, 'ui.FlutterView', has no unnamed constructor that takes no arguments.
  _FlutterView({required this.configuration});
  ^^^^^^^^^^^^
: Error: 'AssetManifest' is imported from both 'package:flutter/src/services/asset_manifest.dart' and 'package:printing/src/fonts/manifest.dart'.
    if (await AssetManifest.contains(asset)) {
              ^^^^^^^^^^^^^
Target kernel_snapshot failed: Exception

FAILURE: Build failed with an exception.

* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1154
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\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 1m 33s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

And when i solved this error by adding this in my pubspec.yaml file and i alaso added some other dependencies because of conflicts


dependency_overrides:
  firebase_core: ^2.5.0
  firebase_core_platform_interface: ^4.5.3
  modal_bottom_sheet:
    git:
      url: https://github.com/danReynolds/modal_bottom_sheet.git
      path: modal_bottom_sheet

after adding this i am getting below error

2

FAILURE: Build failed with an exception.

* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1154

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\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 48s
Launching lib\main.dart on SM J600G in debug mode...
main.dart:1
: Error: 'AssetManifest' is imported from both 'package:flutter/src/services/asset_manifest.dart' and 'package:printing/src/fonts/manifest.dart'.
font.dart:47
    if (await AssetManifest.contains(asset)) {
              ^^^^^^^^^^^^^
Target kernel_snapshot failed: Exception
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

Here is my pubspec.yaml file


name: demandium
description: A new Flutter application.
publish_to: 'none' #
version: 1.0.0+1

environment:
  sdk: ">=2.12.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  get: ^4.6.5
  intl: ^0.17.0
  shared_preferences: ^2.0.15
  connectivity_plus: ^2.3.3
  firebase_core: ^1.24.0
  firebase_messaging: ^13.1.0
  path_provider: ^2.0.11
  url_strategy: ^0.2.0
  image_picker: ^0.8.5+3
  cached_network_image: ^3.2.1
  google_maps_flutter: ^2.1.10
  google_maps_flutter_web: ^0.4.0+1
  geolocator: ^9.0.1
  url_launcher: ^6.1.3
  country_code_picker: ^2.0.2
  phone_number: ^1.0.0
  webview_flutter: ^3.0.4
  pin_code_fields: ^7.4.0
  flutter_widget_from_html_core: ^0.8.5+3
  flutter_typeahead: ^4.0.0
  pointer_interceptor: ^0.9.3+2

  flutter_downloader: ^1.8.3
  permission_handler: ^10.0.0
  fluttertoast: ^8.0.9
  printing: ^5.9.3
  google_sign_in_web: ^0.10.2
  firebase_core_platform_interface: 4.5.1

  pdf: ^3.1.0
  open_file_safe: ^3.2.3
  fwfh_selectable_text: ^0.8.3+1
  diffutil_dart: ^3.0.0

  shimmer_animation: ^2.1.0+1
  carousel_slider: ^4.1.1

  flutter_html: ^3.0.0-alpha.5
  flutter_local_notifications: ^9.5.3+1

  smooth_page_indicator: ^1.0.0+2

  timelines: ^0.1.0
  expandable: ^5.0.1

  universal_html:

  file_picker: ^4.6.1

  google_sign_in: ^5.4.4      
  flutter_facebook_auth: ^4.4.1+1          # available - 5.0.7 
  flutter_inappwebview: ^5.7.1
  timeago: ^3.3.0
  # modal_bottom_sheet: ^2.1.2        # has no effect on code

dependency_overrides:
  firebase_core: ^2.5.0
  firebase_core_platform_interface: ^4.5.3
  modal_bottom_sheet:
    git:
      url: https://github.com/danReynolds/modal_bottom_sheet.git
      path: modal_bottom_sheet

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:
  uses-material-design: true

  assets:
    - assets/images/
    - assets/language/
    - assets/map/
    - assets/

  fonts:
    - family: Ubuntu
      fonts:
        - asset: assets/font/Ubuntu-Light.ttf
          weight: 300
        - asset: assets/font/Ubuntu-Regular.ttf
          weight: 400
        - asset: assets/font/Ubuntu-Medium.ttf
          weight: 500
        - asset: assets/font/Ubuntu-Bold.ttf
          weight: 700

The output of flutter doctor -v is here


[√] Flutter (Channel master, 3.8.0-13.0.pre.22, on Microsoft Windows [Version 10.0.22621.1265], locale en-IN)
    • Flutter version 3.8.0-13.0.pre.22 on channel master at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 911b13784b (30 hours ago), 2023-02-15 02:54:25 -0500
    • Engine revision 44e36c9c0d
    • Dart version 3.0.0 (build 3.0.0-236.0.dev)
    • DevTools version 2.21.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at C:\Users\dhruv\AppData\Local\Android\sdk
    • Platform android-33, build-tools 33.0.1
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.4.4)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.4.33213.308
    • Windows 10 SDK version 10.0.22000.0

[√] Android Studio (version 2022.1)
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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 11.0.15+0-b2043.56-8887301)

[√] VS Code (version 1.75.1)
    • VS Code at C:\Users\dhruv\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.58.0

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22621.1265]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 110.0.5481.77
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 110.0.1587.41

[√] Network resources
    • All expected network resources are available.

• No issues found!

Please help me to resolve this issue.

opxdelwin commented 1 year ago

do try these commands line by line.

flutter clean
flutter pub get

If issue still persists, delete pubspec.lock and go to C:\Users\dhruv\.gradle and delete wrapper folder.

After deleting wrapper folder, come back to your project and run these commands one a time

cd android
./gradlew clean
./gradlew build wrapper
flutter clean ; flutter pub get
quickcodes commented 1 year ago

After passing through all the mentioned steps when I gradlew clean and gradlew build wrapper It failed to build. The output is below


> Configure project :app
WARNING:The option 'android.enableR8' is deprecated.
It was removed in version 7.0 of the Android Gradle plugin.
Please remove it from `gradle.properties`.
WARNING:We recommend using a newer Android Gradle plugin to use compileSdk = 33

This Android Gradle plugin (7.2.1) was tested up to compileSdk = 32

This warning can be suppressed by adding
    android.suppressUnsupportedCompileSdk=33
to this project's gradle.properties

The build will continue, but you are strongly encouraged to update your project to
use a newer Android Gradle Plugin that has been tested with compileSdk = 33

> Task :app:compileFlutterBuildDebug
../../../../../AppData/Local/Pub/Cache/hosted/pub.dev/printing-5.10.1/lib/src/fonts/font.dart:47:15: Error: 'AssetManifest' is imported from both 'package:flutter/src/services/asset_manifest.dart' and 'package:printing/src/fonts/manifest.dart'.
    if (await AssetManifest.contains(asset)) {
              ^^^^^^^^^^^^^
Target kernel_snapshot failed: Exception

> Task :app:compileFlutterBuildDebug FAILED

FAILURE: Build failed with an exception.

* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1154

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.4/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 46s
1 actionable task: 1 executed
darshankawar commented 1 year ago

@quickcodes Please check this and see if it helps in your case.

quickcodes commented 1 year ago

I tried all the steps of that link. Nothing working :(

quickcodes commented 1 year ago

I am unable to understand what causing this issue is it Flutter's issue or my project's...??? I am developing app in flutter from more than a year. I never faced any issue like this.

quickcodes commented 1 year ago

should I reinstall flutter?

quickcodes commented 1 year ago

Thanks for helping me! issue got solved. I deeply read everything mentioned in error and mention in the link provided upper. and It got solved. I changed file called src/font/font.dart inside my cache with the given file in the link :)

phongnv96 commented 1 year ago

link

Can you explain in more detail?

quickcodes commented 1 year ago

Repair cache file by Replacing below code in the file located at somewhere

../../../../../AppData/Local/Pub/Cache/hosted/pub.dev/printing-5.10.1/lib/src/fonts/font.dart You can find this file by typingfonts/font.dart in android's studio search section

/*
* Copyright (C) 2017, David PHAM-VAN <dev.nfet.net@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
  */

import 'package:flutter/services.dart' as services;
import 'package:pdf/widgets.dart';

import '../cache.dart';
import 'manifest.dart' as manifest;

/// Downloadable font object
class DownloadableFont {
/// Create a downloadable font object
const DownloadableFont(this.url, this.name);

/// The Url to get the font from
final String url;

/// The Font filename
final String name;

/// The cache to use
static var cache = PdfBaseCache.defaultCache;

/// Get the font to use in a Pdf document
Future<Font> getFont({
PdfBaseCache? pdfCache,
bool protect = false,
Map<String, String>? headers,
String assetPrefix = 'google_fonts/',
services.AssetBundle? bundle,
bool cache = true,
}) async {
final asset = '$assetPrefix$name.ttf';
if (await manifest.AssetManifest.contains(asset)) {
bundle ??= services.rootBundle;
final data = await bundle.load(asset);
return TtfFont(
data,
protect: protect,
);
}

    pdfCache ??= PdfBaseCache.defaultCache;

    try {
      final bytes = await pdfCache.resolve(
        name: name,
        uri: Uri.parse(url),
        headers: headers,
        cache: cache,
      );

      return TtfFont(
        bytes.buffer.asByteData(bytes.offsetInBytes, bytes.lengthInBytes),
        protect: protect,
      );
    } catch (e) {
      assert(() {
        // ignore: avoid_print
        print('$e\nError loading $name, fallback to Helvetica.');
        return true;
      }());

      return Font.helvetica();
    }
}
}
github-actions[bot] commented 1 year ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.