When building the project, I got the error Namespace not specified, although I already have the string “namespace” in build.gradle
Error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':unityLibrary'.
> 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: C:\Games\Android Builds\unityLibrary\build.gradle. 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 --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 272ms
build.gradle:
apply plugin: 'com.android.application'
dependencies {
implementation project(':unityLibrary')
}
android {
ndkVersion = "19.0.5232133"
namespace 'com.VadGames.Shoter'
compileSdk 29
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion 22
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 29
applicationId 'com.VadGames.Shoter'
ndk {
//noinspection ChromeOsAbiSupport
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86'
}
versionCode 1
versionName '1.0'
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt')
signingConfig signingConfigs.debug
jniDebuggable true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt')
signingConfig signingConfigs.debug
}
}
packagingOptions {
jniLibs {
keepDebugSymbols += ['*/armeabi-v7a/*.so', '*/arm64-v8a/*.so', '*/x86/*.so']
}
}
bundle {
language {
enableSplit = false
}
density {
enableSplit = false
}
abi {
enableSplit = true
}
}
androidResources {
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
noCompress '[\'.unity3d\', \'.ress\', \'.resource\', \'.obb\', \'.bundle\', \'.unityexp\'] + unityStreamingAssets.tokenize(\', \')'
}
lint {
abortOnError false
}
}