Flutter突然无法将apk安装到真机中
我目前正在使用 flutter,当我从设备上卸载应用程序并从终端重新运行 flutter run 时,突然一切都好了,突然无法将 apk 安装到真实设备中.它甚至没有给出任何错误,只是在安装过程中停止.
I am working with flutter currently and everything was fine suddenly when I uninstalled the app from the device and rerun flutter run from the terminal it's suddenly not able to install the apk into a real device. It's not even giving any error just getting stopped at the installation process.
是什么导致了这个问题
我正在使用 sqflite,一切都很好.所以我不得不更改架构并添加另一个失败的表.搜索 SO 回答者建议卸载该应用程序然后重新安装它(已被接受的答案).所以我这样做了,但是每次当我运行 flutter run 之后,它都没有安装 APK.
I was working with sqflite and everything was fine. So I had to change the schema and added another table which was failing. Searching on SO answerer suggested to uninstall the app then reinstall it (was accepted answer). So I did that but after every time when I am running flutter run it is not installing the APK.
我正在运行 Mac Os High Sierra 10.13.6 并运行 flutter doctor 一切正常,因为我说它工作正常但卸载后无法重新安装.
I am running Mac Os High Sierra 10.13.6 and running flutter doctor is giving everything right as I said it was working fine but not reinstalling after uninstalling.
问题
从主页卸载应用会导致后续的 flutter run
命令在安装阶段挂起.
Problem
Uninstalling the app from the home page would cause subsequent flutter run
commands to hang at the installing stage.
Running with flutter run -v
显示它安装成功,但当 adb 尝试运行它时,Activity 无法运行.
Running with flutter run -v
showed that it installed successfully but the activity would not run when adb tried to run it.
错误消息是 3 类 ${packageName}/${packagName}.MainActivity
未找到.
The error message was class 3 ${packageName}/${packagName}.MainActivity
not found.
更改 android 应用程序包名称会使其再次运行,直到我从手机上手动卸载它.
Changing the android app package name would cause it to work again until I uninstalled it manually from the phone.
- 多次重启手机
-
flutter clean
没用 - 重新启动 Android Studio
- 重新启动我的计算机
- 重新启用 USB 调试
- 从 USB 调试中撤销和授权我的计算机
- 重新启用开发者模式
-
adb shell pm list package ${packageName}
没有在列表中显示它,所以没有什么可以清理的
- Rebooting the phone multiple times
-
flutter clean
didn't work - Restarting Android studio
- Restarting my computer
- Re-enabling USB debugging
- Revoking and authorizing my computer from USB debugging
- Re-enabling developer mode
-
adb shell pm list package ${packageName}
didn't show it in the list so there was nothing to clean through there
永久修复
adb uninstall ${packageName}
并显示成功".现在后续的 flutter 运行完美无缺.
Permanent fix
adb uninstall ${packageName}
and it showed 'Success'. Now subsequent flutter runs work perfectly.
似乎从主屏幕卸载应用程序确实会在某个缓存中的某个地方留下一些意图或活动.
It seems uninstalling apps from the home screen does leave some intent or activities in some cache somewhere.