Flutter在启动时崩溃:在路径DexPathList上找不到类.MainActivity

更新时间:2022-01-25 19:16:40

我的发现表明,这不是Flutter本身的问题,而是在特定的Flutter软件包安装之后发生的.升级Gradle和AndroidX库之后,崩溃消失了,然后在添加了Flutter软件包之后又重新出现了.然后我再次清理了android项目中的( build-> clean ) android项目,并再次对其进行了修复.因此,这可能是由于我的环境中存在某些Gradle混乱而造成的,并且可能只是它不时以正确的方式来编译某些类.

My findings suggest this is not an issue with Flutter itself, but occurs after particular Flutter package installations. After upgrading Gradle and the AndroidX libraries, the crash disappeared and then re-appeared after another Flutter package addition. Then I cleaned (build->clean in the IDE) the android project again and it was fixed once again. So it may be due to some Gradle confusions in my environment and probably it just doesn't compile some classes the right way from time to time.