如何使用Flutter调试“无法在设备上安装APK”错误

时间:2019-07-17 14:28:39

标签: android flutter

我是Android开发的新手,两者都很忙。我正在尝试开始抖动,并且在设备上执行默认示例时遇到了问题。

以下是我遵循的相关步骤:

  • 下载并解压缩Flutter。确保正确安装和配置了Android SDK,git和其他先决条件,以防抖动
  • flutter创建myapp
  • cd myapp
  • flutter运行-v

Flutter run无法在我的手机上启动应用程序,并以错误无法安装APK 结尾。

请注意,我从未能够在设备上以调试模式运行flutter应用程序

我尝试了很多事情,下面是发现结果

  1. 如果我使用Flutter在Android Studio中尝试,则会出现相同的错误。
  2. 我能够使用Android Studio(无波动)运行本机Android应用
  3. 我能够在Flutter上运行该应用的发布版本,但不能在调试版本上运行

如何获取Flutter调试版本以在设备上运行?

下面是输出的一些相关部分

Dev平台

 • OS: Windows 7 Ultimate Service pack 1 (64 bit)
 • CPU: AMD FX 8320

颤抖的医生

[√] Flutter (Channel stable, v1.7.8+hotfix.3, on Microsoft Windows [Version 6.1.7601], locale en-US)
    • Flutter version 1.7.8+hotfix.3 at D:\Android\Flutter_v1.7.8
    • Framework revision b712a172f9 (8 days ago), 2019-07-09 13:14:38 -0700
    • Engine revision 54ad777fd2
    • Dart version 2.4.0

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
    • Android SDK at D:\Android\Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.1
    • ANDROID_HOME = D:\Android\Sdk
    • ANDROID_SDK_ROOT = D:\Android\Sdk
    • Java binary at: D:\Android\Android-Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
    • All Android licenses accepted.

[√] Android Studio (version 3.4)
    • Android Studio at D:\Android\Android-Studio
    • Flutter plugin version 37.0.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[!] IntelliJ IDEA Community Edition (version 2019.1)
    • IntelliJ at D:\Program Files\IntelliJ-IDEA-2019.1.3-jbr11
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
    • For information about installing plugins, see
      https://flutter.dev/intellij-setup/#installing-the-plugins

[√] Connected device (1 available)
    • ONEPLUS A5000 • 9586e89d • android-arm64 • Android 9 (API 28)

颤动运行(仅结束输出,因为完整输出太长)

[ +159 ms] Installing APK.
[   +6 ms] executing: D:\Android\Sdk\platform-tools\adb.exe version
[  +49 ms] Android Debug Bridge version 1.0.41
           Version 29.0.1-5644136
           Installed as D:\Android\Sdk\platform-tools\adb.exe
[   +3 ms] executing: D:\Android\Sdk\platform-tools\adb.exe start-server
[  +41 ms] Installing build\app\outputs\apk\app.apk...
[   +1 ms] executing: D:\Android\Sdk\platform-tools\adb.exe -s 9586e89d install -t -r
D:\BackedupFolder\DevProjects\AndroidStudioProjects\myapp\build\app\outputs\apk\app.apk
[+1777 ms] Performing Streamed Install

           adb: failed to install D:\BackedupFolder\DevProjects\AndroidStudioProjects\myapp\build\app\outputs\apk\app.apk:
[   +3 ms] Installing build\app\outputs\apk\app.apk... (completed in 1.8s)
[   +2 ms] Error: ADB exited with exit code 1
[   +3 ms] Performing Streamed Install

           adb: failed to install D:\BackedupFolder\DevProjects\AndroidStudioProjects\myapp\build\app\outputs\apk\app.apk:
[   +3 ms] Warning: Failed to install APK.
[   +1 ms] Error launching application on ONEPLUS A5000.
[   +5 ms] "flutter run" took 43,368ms.
[   +1 ms] "flutter run" took 43,368ms.

#0      throwToolExit (package:flutter_tools/src/base/common.dart:28:3)
#1      RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:475:7)
<asynchronous suspension>
#2      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:478:18)
<asynchronous suspension>
#3      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:383:33)
<asynchronous suspension>
#4      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:29)
<asynchronous suspension>
#5      _rootRun (dart:async/zone.dart:1124:13)
#6      _CustomZone.run (dart:async/zone.dart:1021:19)
#7      _runZoned (dart:async/zone.dart:1516:10)
#8      runZoned (dart:async/zone.dart:1463:12)
#9      AppContext.run (package:flutter_tools/src/base/context.dart:152:18)
<asynchronous suspension>
#10     FlutterCommand.run (package:flutter_tools/src/runner/flutter_command.dart:375:20)
#11     CommandRunner.runCommand (package:args/command_runner.dart:197:27)
<asynchronous suspension>
#12     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:396:21)
<asynchronous suspension>
#13     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:29)
<asynchronous suspension>
#14     _rootRun (dart:async/zone.dart:1124:13)
#15     _CustomZone.run (dart:async/zone.dart:1021:19)
#16     _runZoned (dart:async/zone.dart:1516:10)
#17     runZoned (dart:async/zone.dart:1463:12)
#18     AppContext.run (package:flutter_tools/src/base/context.dart:152:18)
<asynchronous suspension>
#19     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:356:19)
<asynchronous suspension>
#20     CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:112:25)
#21     new Future.sync (dart:async/future.dart:224:31)
#22     CommandRunner.run (package:args/command_runner.dart:112:14)
#23     FlutterCommandRunner.run (package:flutter_tools/src/runner/flutter_command_runner.dart:242:18)
#24     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:22)
<asynchronous suspension>
#25     _rootRun (dart:async/zone.dart:1124:13)
#26     _CustomZone.run (dart:async/zone.dart:1021:19)
#27     _runZoned (dart:async/zone.dart:1516:10)
#28     runZoned (dart:async/zone.dart:1500:12)
#29     run.<anonymous closure> (package:flutter_tools/runner.dart:60:18)
<asynchronous suspension>
#30     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:29)
<asynchronous suspension>
#31     _rootRun (dart:async/zone.dart:1124:13)
#32     _CustomZone.run (dart:async/zone.dart:1021:19)
#33     _runZoned (dart:async/zone.dart:1516:10)
#34     runZoned (dart:async/zone.dart:1463:12)
#35     AppContext.run (package:flutter_tools/src/base/context.dart:152:18)
<asynchronous suspension>
#36     runInContext (package:flutter_tools/src/context_runner.dart:56:24)
<asynchronous suspension>
#37     run (package:flutter_tools/runner.dart:51:10)
#38     main (package:flutter_tools/executable.dart:62:9)
<asynchronous suspension>
#39     main (file:///C:/b/s/w/ir/k/archive/flutter/packages/flutter_tools/bin/flutter_tools.dart:8:3)
#40     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#41     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)

1 个答案:

答案 0 :(得分:0)

似乎您的已连接设备正在运行Android-28,目标平台是Android-29。由于您的设备运行的版本比您的构建版本小,因此简单的修复可能是将已连接的设备更新为Android 28。 然后再次检查硬件设备上的开发人员选项是否“打开”并且设置正确。具体检查“ USB调试”是否已打开,“​​等待调试器”是否已打开以及“验证debuggalbe应用程序的字节码”是否已关闭。 ScreenShot