未指定命名空间gradleKotlinDSL?

i2byvkas  于 2023-08-07  发布在  Kotlin
关注(0)|答案(2)|浏览(156)

我正在使用KotlinDSL进行构建
这是应用程序级构建gradle

plugins {
id("com.android.application")
kotlin("android")
}

android {
namespace = "com.jioads.test"
compileSdk = AppConfig.compile
buildToolsVersion = AppConfig.buildToolsVersion
defaultConfig {
    applicationId = (AppConfig.appId)
    minSdk = AppConfig.minSdk
    targetSdk = AppConfig.target
    versionCode = AppConfig.versionCode
    versionName = AppConfig.versionName

    testInstrumentationRunner = AppConfig.androidTestInstrumentation
}

buildTypes {
    getByName("release") {
        isMinifyEnabled = false
        proguardFiles(
            getDefaultProguardFile("proguard-android-optimize.txt"),
            "proguard-rules.pro"
        )
    }
}
viewBinding {
    android.buildFeatures.viewBinding = true
}
compileOptions {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
    jvmTarget = "1.8"
}
}

dependencies {
//std lib
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
//app libs
implementation(Dependencies.appLibraries)
//test libs
testImplementation(Dependencies.testLibraries)
androidTestImplementation(Dependencies.androidTestLibraries)
implementation(project(":jio-ads-sdk"))
}

字符串
AGP版本为8.0.2 Gradle版本为8.0
我收到以下错误

Namespace not specified. Please specify a namespace in the module's build.gradle file like so:

android {
namespace 'com.example.namespace'
}

x8diyxa7

x8diyxa71#

如果":jio-ads-sdk"是android模块,检查模块中是否指定了namespace。

k4ymrczo

k4ymrczo2#

首先,您可以从所有Kotlingradle DSL文件中删除所有命名空间。其次,请在android manifest文件中将命名空间作为包名添加到相应的模块中。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.jioads.test">
</manifest>

字符串

相关问题