我想构建一个使用蓝牙的应用程序。我阅读了在“依赖项”部分下的 pubspec.yaml 文件中添加“flutterblue:”的内容。但是当我添加这一行,在终端中运行“flutter pub get”并尝试在模拟器或真实手机上运行该应用程序时,我收到以下错误:
A problem occurred configuring project ':flutter_blue'.
Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.
Namespace not specified. Specify a namespace in the module's build file.
See https://d.android.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace. If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to https://d.android.com/r/tools/upgrade-assistant/agp-upgrade-assistant for general information about using the AGP Upgrade Assistant.
有人知道这里出了什么问题吗?
我预计不会出现错误,因为我只添加了包。我还没有编写一行使用该包的代码。我创建了一个新的 flutter 项目,并尝试运行一个简单的“hello world”代码,并在 pubspec.yaml 文件中添加了相同的“flutter_blue”行。但我又犯了同样的错误
从根文件夹转到: android > 应用程序 > build.gradle
像这样:
然后:
找到它所在的行:
android { ...
添加这一行:
android {
namespace = "com.example.your_app_name"
...
}