# Build Gradle failed in Unity 6 

**URL:** <https://forums.unrealengine.com/t/build-gradle-failed-in-unity-6/2858381>\
**Category:** Multiplayer\
**Tags:** epic-online-services, question\
**Created:** [September 13, 2025, 11:08pm UTC](https://forums.unrealengine.com/t/build-gradle-failed-in-unity-6/2858381 "2025-09-13T23:08:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous-edc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous-edc](https://forums.unrealengine.com/u/anonymous-edc)\
**Post date:** [September 13, 2025, 11:08pm UTC](https://forums.unrealengine.com/t/build-gradle-failed-in-unity-6/2858381/1 "2025-09-13T23:08:23Z")

</div>

I’m getting this error:

FAILURE: Build failed with an exception. \* What went wrong: A problem occurred configuring project ‘:unityLibrary:eos\_dependencies.androidlib’. \> 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](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](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](https://help.gradle.org).

`What I need to do in order to solve it?`

---

<div class="post-metadata">

**Author:** ![JskT01xa](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JskT01xa](https://forums.unrealengine.com/u/JskT01xa)\
**Post date:** [October 9, 2025, 9:33pm UTC](https://forums.unrealengine.com/t/build-gradle-failed-in-unity-6/2858381/2 "2025-10-09T21:33:58Z")

</div>

Hi! We already have the steps to adapt the project to Unity 6. I’m sharing them here, and I’ll keep an eye out in case you run into any errors or issues.

Regarding the specific error you’re encountering, the solution is:

Unity 6 migrated to a new Gradle project generation system based on Android Gradle Plugin (AGP) 8.x, which introduces mandatory changes to how Android modules are defined.

Projects must now explicitly define a namespace, use JavaVersion.VERSION\_17, and enable core library desugaring to maintain compatibility with Java 8+ APIs.

You must use custom Gradle templates to ensure the correct Android toolchain versions are applied.

launcherTemplate.gradle

```auto
    apply plugin: 'com.android.application'
    apply from: 'setupSymbols.gradle'
    apply from: '../shared/keepUnitySymbols.gradle'

    dependencies {
    implementation project(':unityLibrary')
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
    }

    android {
    namespace " **NAMESPACE**"
    ndkPath " **NDKPATH**"
    ndkVersion " **NDKVERSION**"

    compileSdk **APIVERSION**
    buildToolsVersion = " **BUILDTOOLS**"

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
        coreLibraryDesugaringEnabled true
    }

    defaultConfig {
        minSdk **MINSDK**
        targetSdk **TARGETSDK**
        applicationId ' **APPLICATIONID**'
        ndk {
            abiFilters **ABIFILTERS**
            debugSymbolLevel **DEBUGSYMBOLLEVEL**
        }
        versionCode **VERSIONCODE**
        versionName ' **VERSIONNAME**'
    }

    androidResources {
        noCompress = **BUILTIN_NOCOMPRESS** + unityStreamingAssets.tokenize(', ')
        ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~"
    } **SIGN**

    lint {
        abortOnError false
    }

    buildTypes {
        debug {
            minifyEnabled **MINIFY_DEBUG**
            proguardFiles getDefaultProguardFile('proguard-android.txt') **SIGNCONFIG**
            jniDebuggable true
        }
        release {
            minifyEnabled **MINIFY_RELEASE**
            proguardFiles getDefaultProguardFile('proguard-android.txt') **SIGNCONFIG**
        }
    } **PACKAGING**** PLAY_ASSET_PACKS ****SPLITS**
    **BUILT_APK_LOCATION**
    bundle {
        language {
            enableSplit = false
        }
        density {
            enableSplit = false
        }
        abi {
            enableSplit = true
        }
        texture {
            enableSplit = true
        }
    }

	**GOOGLE_PLAY_DEPENDENCIES**
    } **SPLITS_VERSION_CODE**** LAUNCHER_SOURCE_BUILD_SETUP**

```

mainTemplate.gradle

```auto
    apply plugin: 'com.android.library'
    apply from: '../shared/keepUnitySymbols.gradle'
    **APPLY_PLUGINS**

    android {
    namespace "com.unity3d.player"
    ndkPath " **NDKPATH**"
    ndkVersion " **NDKVERSION**"

    compileSdk **APIVERSION**
    buildToolsVersion = " **BUILDTOOLS**"

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
        coreLibraryDesugaringEnabled true
    }

    defaultConfig {
        minSdk **MINSDK**
        targetSdk **TARGETSDK**
        ndk {
            abiFilters **ABIFILTERS**
            debugSymbolLevel **DEBUGSYMBOLLEVEL**
        }
        versionCode **VERSIONCODE**
        versionName ' **VERSIONNAME**'
        consumerProguardFiles 'proguard-unity.txt' **USER_PROGUARD**
    **DEFAULT_CONFIG_SETUP**
    }

    lint {
        abortOnError false
    }

    androidResources {
        noCompress = **BUILTIN_NOCOMPRESS** + unityStreamingAssets.tokenize(', ')
        ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~"
    } **PACKAGING**
    }
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        **DEPS**
        coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
    }
    **IL_CPP_BUILD_SETUP**
    **SOURCE_BUILD_SETUP**
    **EXTERNAL_SOURCES**

```

gradleTemplate.properties

```auto
    org.gradle.jvmargs=-Xmx **JVM_HEAP_SIZE** M
    org.gradle.parallel=true
    unityStreamingAssets= **STREAMING_ASSETS**
    **ADDITIONAL_PROPERTIES**
    android.useAndroidX=true

```

For Unity 6, you must modify the build.gradle file located at:

`<project>\Library\PackageCache\com.playeveryware.eos@b4c7aa785817\PlatformSpecificAssets~\EOS\Android\eos_dependencies.androidlib\build.gradle`

This folder is automatically generated when importing the EOS package into Unity. The default Gradle configuration inside it must be replaced with the following content to ensure proper compilation and namespace compatibility in Unity 6.

build.gradle

```auto
    buildscript {
    repositories {
        google()
        mavenCentral()
        flatDir(dirs: 'libs')
    }

    dependencies {
        classpath "com.android.tools.build:gradle:7.4.2"
    }
    }

    apply plugin: 'com.android.library'
    repositories {
    google()
    mavenCentral()
    flatDir {
        dirs 'libs'
    }
    }
    android {
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
            jniLibs.srcDirs = ['libs']
        }
    }
    namespace 'com.pew.eos_dependencies'
    compileSdkVersion 34
    buildToolsVersion '34.0.0'
    defaultConfig {
        targetSdkVersion 34
    }
    }
    dependencies {
        implementation 'androidx.appcompat:appcompat:1.5.1'
        implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
        implementation 'androidx.security:security-crypto:1.0.0'
        implementation 'androidx.browser:browser:1.4.0'
    //api fileTree(dir: 'libs', include: ['*.aar'])
    }

```

If you do not define a namespace, Android Gradle Plugin 8.0+ will fail with the error: Namespace not specified. Specify a namespace in the module’s build file.

Additionally, you must edit the AndroidManifest.xml file located at:

`<project>\Library\PackageCache\com.playeveryware.eos@b4c7aa785817\PlatformSpecificAssets~\EOS\Android\eos_dependencies.androidlib\AndroidManifest.xml`

The manifest file contains the line , which is no longer accepted in Unity 6 due to updated Android Gradle Plugin validation rules.

You must replace its contents with the following version to ensure proper compatibility:

```auto
    <manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <application
        android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">
    </application>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    </manifest>

```

Let me know if this works or if you have any questions. I’m here to help!

---

<div class="post-metadata">

**Author:** ![JskT01xa](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JskT01xa](https://forums.unrealengine.com/u/JskT01xa)\
**Post date:** [October 9, 2025, 9:38pm UTC](https://forums.unrealengine.com/t/build-gradle-failed-in-unity-6/2858381/3 "2025-10-09T21:38:25Z")

</div>

If you encounter the following error during build:

```auto
A failure occurred while executing MergeNativeLibsTask:
2 files found with path 'lib/arm64-v8a/libc++_shared.so'

```

Remove the conflicting **UnityHelpers\_Android-debug.aar** file or any duplicated .so libraries located in:

`<project>\Library\PackageCache\com.playeveryware.eos@b4c7aa785817\Runtime\Android`

Unity 6 now merges all native libraries automatically, so duplicated entries will cause a build failure.

---

<div class="post-metadata">

**Author:** ![anonymous-edc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous-edc](https://forums.unrealengine.com/u/anonymous-edc)\
**Post date:** [November 27, 2025, 3:59am UTC](https://forums.unrealengine.com/t/build-gradle-failed-in-unity-6/2858381/4 "2025-11-27T03:59:43Z")

</div>

This solved my problems! thank you so much!

---

<div class="post-metadata">

**Author:** ![anonymous-edc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous-edc](https://forums.unrealengine.com/u/anonymous-edc)\
**Post date:** [April 26, 2026, 5:22pm UTC](https://forums.unrealengine.com/t/build-gradle-failed-in-unity-6/2858381/5 "2026-04-26T17:22:09Z")

</div>

Still working for Unity 6.3! and EOS plugin version 6.02
