我创建了一个新的 flutter 项目,并使用了一些包(包括 firebase 包),当我尝试运行该应用程序时,它显示此错误

问题描述 投票:0回答:1
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':scan'.
> 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 2s
Error: Gradle task assembleDebug failed with exit code 1

我尝试修改compileSdk = 34,minSdkVersion 21,targetSdkVersion 34并定义命名空间

flutter dart gradle build.gradle
1个回答
0
投票

找到文件android/app/build.gradle

在此设置正确的包名称。

android {
  namespace = "com.example.scan" //set proper package name
  .....
}
© www.soinside.com 2019 - 2024. All rights reserved.