【发布时间】:2018-10-11 18:38:55
【问题描述】:
TL;DR
将url_launcher 添加到我的pubspec 后,我无法再在Android 中启动我的应用程序。开始时,我在 Logcat 中得到以下输出:Didn't find class "$prefix.$projectname.MainActivity" on path: DexPathList[[zip file "/data/app/...,其中$prefix.$projectname 不是正确的包,因为我将其更改为$prefix.$name,其中name 是其他字符串。
一旦我再次删除url_launcher,我的应用程序就会正常启动。
综合
当只添加url_launcher 到我的pubspec.yaml 文件时,我的应用程序将无法在Android 上启动。我什至不必在我的代码中使用它。
经过进一步调查,我在 Logcat for Android 中发现了一条日志消息:Didn't find class "$prefix.$projectname.MainActivity" on path: DexPathList[[zip file "/data/app/...。这就是错误的根源!
我在创建项目之后 更改了我的包名,因为 Flutter 仍然存在问题 :) 在创建向导中,我输入了 $prefix.$name(这些只是变量; prefix 总是相同的,其他两个也一样;作为参考,请查看错误消息,我也将其插入其中。在我第一次构建时,包名称原来是 $packagename.$projectname。我找到了解决方法:更改 Android src 目录中的代码目录名称并更改 build.gradle 中的 applicationId 名称。
所以现在我的包名是$prefix.$name。我的 Android Studio 项目名称/文件夹仍然是 projectname。在我的pubspec 中没有url_launcher 一切正常,但是添加它时会创建一个目录,如下所示:
没有url_launcher:
project/build/app:
-generated
-intermediates
-outputs
-tmp
添加url_launcher后,build目录中突然出现另一个目录(除了app):
project/build/app:
-generated
-intermediates
-outputs
-tmp
project/build/url_launcher:
-generated
-intermediates
-outputs
-tmp
build 目录中的url_launcher 目录与app 目录具有相同的子目录。我之所以提到这一点,是因为我不确定这是否是不受欢迎的行为。
【问题讨论】:
标签: android android-studio dart flutter