android 如何将命名空间添加到所有模块build.gradle Flutter中?

k3bvogb1  于 2023-10-14  发布在  Android
关注(0)|答案(1)|浏览(187)

在我更新我的gradle到8.0后,如果我在android build.gradle中设置了命名空间,则在构建apk事件时会出现错误命名空间
这是我的build gradle代码

build.gradle:android/app

android {
    compileSdkVersion localProperties.getProperty('flutter.compileSdkVersion').toInteger()//33
    namespace 'com.appidname.here'
    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        applicationId "com.appidname.here"
        minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()//21
        targetSdkVersion localProperties.getProperty('flutter.targetSdkVersion').toInteger()//33
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
     ....
}

build.gradle:android

buildscript {
    ext.kotlin_version = '1.8.22'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:8.0.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
....

这是我得到的错误时,buil apk或appbuble.

错误

* What went wrong:
A problem occurred configuring project ':webview_pro_android'.
> Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.
   > Namespace not specified. Please specify a namespace in the module's build.gradle file like so:

     android {
         namespace 'com.example.namespace'
     }

从错误我认为命名空间不设置在所有的插件模块还。如何解决这个问题,如何为所有插件模块添加命名空间?谢谢

zsohkypk

zsohkypk1#

你可以像这样修改你的build.gradle文件。

android {
    namespace 'your_package_name'
    compileSdk 34

    defaultConfig {
        applicationId "your_package_name"
        minSdk 24
        targetSdk 34
        versionCode 1
        versionName "1.0"
    }
}

相关问题