flutter 使用 isar_flutter_libs 安卓构建报错如何解决?

56 阅读1分钟

报错信息

A problem occurred configuring project ':isar_flutter_libs'. > 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 d.android.com/r/tools/upg… 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 d.android.com/r/tools/upg… for general information about using the AGP Upgrade Assistant.

解决办法

  1. 在 android >> build.gradle 文件中,新增一个 subprojects
  2. 需要注意位置,在 subprojects { project.evaluationDependsOn(":app") }前面新增。
  3. 原文链接:stackoverflow.com/questions/7… stackoverflow.com/questions/7…
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
// 添加如下 subprojects
subprojects {
    afterEvaluate { project ->
        if (project.hasProperty('android')) {
            project.android {
                if (namespace == null) {
                    namespace project.group
                }
            }
        }
    }
}
subprojects {
    project.evaluationDependsOn(":app")
}