为什么我的 Flutter 应用程序出现命名空间错误?

问题描述 投票:0回答:1

我正在尝试开发我的 Flutter 应用程序,并且我已迁移到 Flutter 插件的声明式应用。然而,这现在造成了另一个问题,我不知道如何解决。

Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':android_intent'.
> 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.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
Error: Gradle task assembleDebug failed with exit code 1

错误如上所示,我不明白为什么会出现错误。我还在 app/build.gradle 文件中定义了一个命名空间,但我完全迷失了。任何帮助将不胜感激!

android {
    namespace "com.example.cyclesync"
    compileSdkVersion 34
    ndkVersion flutter.ndkVersion
flutter dart compiler-errors
1个回答
0
投票

我建议从项目中删除 android 文件夹,然后在项目根目录的终端中运行以下命令:

flutter create .

此命令将重新创建干净的 android 文件夹,并有望解决命名空间问题。

© www.soinside.com 2019 - 2024. All rights reserved.