1

我在构建我的应用程序时遇到问题,它一直给我这个Invalid depfile: C:\Users\kg3bo\AndroidStudioProjects\pomastore\.dart_tool\flutter_build\f3e5966fddb8025853f2e4961407d23d\kernel_snapshot.d我尝试使用的错误flutter pub getflutter pub upgrade并删除 kernel_snapshot.d 然后用于flutter pub get重新生成它,但它没有工作。这是我的完整代码:

pubspec.yaml:

name: pomastore
description: A new Flutter project.

# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=2.12.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  webview_flutter: ^1.0.7
  font_awesome_flutter: ^8.11.0


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_launcher_icons: ^0.9.0

flutter_icons:
  image_path: "asset/images/1.png"
  android: true
  ios: true
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true
  assets:
    - asset/images/1.png
  # To add assets to your application, add an assets section, like this:
  # assets:
  #   - images/a_dot_burr.jpeg
  #   - images/a_dot_ham.jpeg

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

主要飞镖:

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: SplashScreen(),
    );
  }
}

class SplashScreen extends StatefulWidget {
  @override
  _SplashScreenState createState() => _SplashScreenState();
}

class _SplashScreenState extends State<SplashScreen> {
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    Timer(Duration(seconds: 3), () {
      Navigator.of(context)
          .pushReplacement(MaterialPageRoute(builder: (_) => HomePage()));
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.teal[700],
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            // logo here
            Image.asset(
              'asset/images/1.png',
              height: 120,
            ),
            SizedBox(
              height: 20,
            ),
            CircularProgressIndicator(
              valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
            )
          ],
        ),
      ),
    );
  }
}

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: WebView(
          initialUrl: "https://poma.app",
          javascriptMode: JavascriptMode.unrestricted,
        ),
      ),
    );
  }
}

构建后的输出:

C:\flutter\bin\flutter.bat --no-color build appbundle

 Building with sound null safety 

Running Gradle task 'bundleRelease'...                          

Invalid depfile: C:\Users\kg3bo\AndroidStudioProjects\pomastore\.dart_tool\flutter_build\f3e5966fddb8025853f2e4961407d23d\kernel_snapshot.d
Invalid depfile: C:\Users\kg3bo\AndroidStudioProjects\pomastore\.dart_tool\flutter_build\f3e5966fddb8025853f2e4961407d23d\kernel_snapshot.d


Invalid depfile: C:\Users\kg3bo\AndroidStudioProjects\pomastore\.dart_tool\flutter_build\f3e5966fddb8025853f2e4961407d23d\kernel_snapshot.d
Invalid depfile: C:\Users\kg3bo\AndroidStudioProjects\pomastore\.dart_tool\flutter_build\f3e5966fddb8025853f2e4961407d23d\kernel_snapshot.d
Invalid depfile: C:\Users\kg3bo\AndroidStudioProjects\pomastore\.dart_tool\flutter_build\f3e5966fddb8025853f2e4961407d23d\kernel_snapshot.d
Invalid depfile: C:\Users\kg3bo\AndroidStudioProjects\pomastore\.dart_tool\flutter_build\f3e5966fddb8025853f2e4961407d23d\kernel_snapshot.d
Invalid depfile: C:\Users\kg3bo\AndroidStudioProjects\pomastore\.dart_tool\flutter_build\f3e5966fddb8025853f2e4961407d23d\kernel_snapshot.d
Invalid depfile: C:\Users\kg3bo\AndroidStudioProjects\pomastore\.dart_tool\flutter_build\f3e5966fddb8025853f2e4961407d23d\kernel_snapshot.d
Invalid depfile: C:\Users\kg3bo\AndroidStudioProjects\pomastore\.dart_tool\flutter_build\f3e5966fddb8025853f2e4961407d23d\kernel_snapshot.d
Invalid depfile: C:\Users\kg3bo\AndroidStudioProjects\pomastore\.dart_tool\flutter_build\f3e5966fddb8025853f2e4961407d23d\kernel_snapshot.d
Invalid depfile: C:\Users\kg3bo\AndroidStudioProjects\pomastore\.dart_tool\flutter_build\f3e5966fddb8025853f2e4961407d23d\kernel_snapshot.d
Invalid depfile: C:\Users\kg3bo\AndroidStudioProjects\pomastore\.dart_tool\flutter_build\f3e5966fddb8025853f2e4961407d23d\kernel_snapshot.d


Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:

 - package:webview_flutter

For solutions, see https://dart.dev/go/unsound-null-safety


FAILURE: Build failed with an exception.

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

* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command 'C:\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 9s
Running Gradle task 'bundleRelease'...                             10.1s
Gradle task bundleRelease failed with exit code 1
Process finished with exit code 1
4

0 回答 0