Android studio模拟器:启动应用程序时出错?

时间:2020-10-01 20:36:22

标签: android flutter dart

我正在尝试将代码运行到Flutter应用中! 我尝试运行main.dart,但是当我运行代码时,它在模拟器上不起作用

这是我的代码:

    import 'package:flutter/material.dart';

void main() =>
    runApp(MaterialApp(
      home : NinjaCard () ,

  ));
class NinjaCard extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold (
      appBar: AppBar (
        title : Text(' Ninja Card Id ') ,
      ),
    );
  }
}
I try to run my code  on Android Studio emulator and I get this error:


Launching lib\main.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...
√ Built build\app\outputs\apk\debug\app-debug.apk.
cmd: Can't find service: activity
Installing build\app\outputs\apk\app.apk...
Error: ADB exited with exit code 1
Performing Streamed Install

adb: failed to install D:\apps\firas_id\build\app\outputs\apk\app.apk: cmd: Can't find service: package
Error launching application on sdk gphone x86 arm.
Does anyone know how to fix it? Thank you in advance.

1 个答案:

答案 0 :(得分:0)

方法1:

  1. 打开AVD Manager
  2. 擦除数据(从模拟器中删除数据)
  3. 打开模拟器
  4. 尝试运行应用

方法2:

  1. 打开AVD Manager

  2. 按对应于您的小箭头(在笔旁边) 首选设备

  3. 选择“立即冷启动”

  4. 等待仿真器打开并启动

  5. 运行您的应用程序