如何修复Gradle任务assebleDebug失败并在FLUTTER中出现退出代码1错误?

问题描述

我只是试图执行一个基本的应用程序。 整个事情在Windows上运行正常。 但是在Linux上工作失败。 我用的是manjaro Gnome。

我正确配置了环境,并检查了android-studio的路径变量。 Flutter SDK也已正确安装和配置。

代码中未显示任何错误,但由于某些未知原因,构建任务失败。

我试图执行以下代码: 这是main.dart文件

import 'package:Flutter/cupertino.dart';
import 'package:Flutter/material.dart';

void main() {
  runApp(MaterialApp(
    home:NinjaCard(),));
}

class NinjaCard extends StatefulWidget {
  @override
  _NinjaCardState createState() => _NinjaCardState();
}

class _NinjaCardState extends State<NinjaCard> {

  int ninjaLevel = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.grey[900],appBar: AppBar(
        title: Text('Ninja ID Card'),centerTitle: true,backgroundColor: Colors.grey[850],elevation: 0.0,),floatingActionButton: FloatingActionButton(
        elevation: 0.0,onpressed: (){
          setState(() {
            ninjaLevel += 1;
          });
        },child: Icon(Icons.add),backgroundColor: Colors.AmberAccent,body: Padding(
        padding: EdgeInsets.fromLTRB(30.0,40.0,30.0,0.0),child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,children: <Widget>[
            Center(
              child: CircleAvatar(
                backgroundImage: Assetimage('assets/goku.jpg'),radius: 50.0,Divider(
              height: 100.0,color: Colors.grey[800],Text(
              'Name',style: TextStyle(
                color: Colors.grey,letterSpacing: 2.0,SizedBox(height: 10.0),Text(
              'Lucifer Alexander',style: TextStyle(
                color: Colors.AmberAccent[400],fontSize: 28.0,fontWeight: FontWeight.bold,SizedBox(height: 30.0),Text(
              'CURRENT NINJA LEVEL',Text(
              '$ninjaLevel',Row(
              children: <Widget>[
                Icon(
                  Icons.email,color: Colors.grey[400],SizedBox(width: 10.0),Text(
                  'luciferAlexander1234@gmail.com',style: TextStyle(
                    color: Colors.grey[400],fontSize: 18.0,letterSpacing: 1.0,],)
          ],);
  }
}

这是我的pubspec.yaml文件

name: ninja_id
description: A new Flutter application.

# 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.7.0 <3.0.0"

dependencies:
  Flutter:
    sdk: Flutter


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

dev_dependencies:
  Flutter_test:
    sdk: Flutter

# 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

  # To add assets to your application,add an assets section,like this:
  assets:
   - assets/
  # 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

这是由控制台返回的:

Console Image

我们非常感谢您的帮助。 谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)