dart 很遗憾,flutter_app已经停止

hfsqlsce  于 2023-07-31  发布在  Flutter
关注(0)|答案(3)|浏览(181)

我是个初学者。我使用vscode进行开发。我也使用我的物理android设备而不是模拟器进行调试。我构建了一个简单的flutter应用程序。使用Flutter运行执行。构建完成后,我的手机中弹出了白色屏幕,很快就出现了对话框“不幸的是,quiz_app已经停止了。”,其中quiz_app是项目名称。Ryzen-5机器下面是$ flutter -v的输出:

[√] Flutter (Channel stable, v1.12.13+hotfix.8, on Microsoft Windows [Version 10.0.18363.720], locale en-IN)
    • Flutter version 1.12.13+hotfix.8 at C:\src\flutter
    • Framework revision 0b8abb4724 (5 weeks ago), 2020-02-11 11:44:36 -0800
    • Engine revision e1e6ced81d
    • Dart version 2.7.0

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at C:\Users\haari\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
    • All Android licenses accepted.

[!] Android Studio (version 3.6)
    • Android Studio at C:\Program Files\Android\Android Studio
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

字符串
下面是执行$ flutter run时的控制台日志:

Launching lib\main.dart on SM G531F in debug mode...
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                        20.0s
√ Built build\app\outputs\apk\debug\app-debug.apk.
D/FlutterActivity( 8697): Using the launch theme as normal theme.
D/FlutterActivityAndFragmentDelegate( 8697): Setting up FlutterEngine.
D/FlutterActivityAndFragmentDelegate( 8697): No preferred FlutterEngine was provided. Creating a new FlutterEngine for this FlutterFragment.
E/DartVM  ( 8697): version=2.7.0 (Fri Dec 6 16:26:51 2019 +0100) on "android_arm"
E/DartVM  ( 8697): thread=8697, isolate=vm-isolate(0xab699540)
E/DartVM  ( 8697):   pc 0x54cfcfcd fp 0xffcb8e58 libflutter.so+0x1321fcd
E/DartVM  ( 8697): -- End of DumpStackTrace


下面是主要的.dart代码:-

import 'package:flutter/material.dart';

void main() => runApp(QuizApp());

class QuizApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('JIT Quiz App'),
        ),
        body: Column(
          children: <Widget>[
            Text('What is your favourite subject?'),
            RaisedButton(child: Text('DBMS'), onPressed: null),
            RaisedButton(child: Text('DAA'), onPressed: null),
            RaisedButton(child: Text('CA'), onPressed: null),
            RaisedButton(child: Text('PQT'), onPressed: null),
          ],
        ),
      ),
    );
  }
}


我正在尽可能避免使用模拟器进行调试。

7rfyedvj

7rfyedvj1#

您应该先传回MaterialApp()。MaterialApp是应用程序的起点。“它告诉flutter你将在你的应用中使用材料组件。

nqwrtyyt

nqwrtyyt2#

从Android Studio打开您的Android项目,然后在设备中运行应用程序。然后,您将能够在控制台中看到正确的错误消息,因为您的应用程序崩溃。


的数据

s4n0splo

s4n0splo3#

步骤01:在android/app/src/AndroidManifest.xml中添加Internet权限

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
        <uses-permission android:name="android.permission.INTERNET" />
        <application

字符串
步骤02:在android/app/build.gradle中添加

>  buildTypes {
    >         release {
    >             // TODO: Add your own signing config for the release build.
    >             // Signing with the debug keys for now, so `flutter run --release` works.
    >             signingConfig signingConfigs.debug
    >             minifyEnabled false
    >             shrinkResources false
    >             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    >         }
    >     }

对我很有效

相关问题