Environment Setup for Android
January 16, 2026 · View on GitHub
Unity and Modules
The following Unity versions support 16 KB memory page sizes required by Android 15+:
- Unity 2021.3.45f2
- Unity 2022.3.62f2 ✅ Recommended baseline
- Unity 6000.0.58f2
Note
Using Unity versions older than 2021.3.48f1 is not compatible with Android 15+ (16 KB memory pages).
Upgrading to at least 2022.3.56f1 is strongly recommended for most teams.
-
Install Unity (minimum version 2022.3.56f), preferably on Unity Hub.
This version includes JDK 11, which is required for building Android projects.
-
Open the "Add modules" window.
-
Select and install the following modules:
- Windows Build Support (Il2CPP)
- Android SDK & NDK Tools
- OpenJDK
Recommended Configuration for Unity 2022.3
-
General Requirements
- Target API Level: 34 or higher
- Android Build Tools: 33.0.2
- Gradle: 7.5 – 7.6.4
- R8: 8.1.56
-
Gradle Templates Unity 2022 already includes JDK 11, so no manual installation is required.
You must use custom Gradle templates to ensure the correct Android toolchain versions are applied.
baseProjectTemplate.gradle
allprojects { buildscript { repositories { google() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:7.4.2' classpath "com.android.tools:r8:8.1.56" } } repositories { google() mavenCentral() maven { url = uri("https://storage.googleapis.com/r8-releases/raw") } flatDir { dirs "${project(':unityLibrary').projectDir}/libs" } } } task clean(type: Delete) { delete rootProject.buildDir }gradleTemplate.properties
unityStreamingAssets=.unity3d**STREAMING_ASSETS** org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M org.gradle.parallel=true **ADDITIONAL_PROPERTIES** android.enableJetifier=true android.useAndroidX=truemainTemplate.gradle
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN apply plugin: 'com.android.library' **APPLY_PLUGINS** dependencies { implementation 'androidx.credentials:credentials-play-services-auth:1.3.0' implementation 'androidx.credentials:credentials:1.3.0' implementation 'com.google.android.libraries.identity.googleid:googleid:1.1.1' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation fileTree(dir: 'libs', include: ['*.jar']) **DEPS**} android { namespace "com.unity3d.player" ndkPath "**NDKPATH**" compileSdkVersion **APIVERSION** buildToolsVersion '**BUILDTOOLS**' compileOptions { // Important: Required for Android 14+ support sourceCompatibility JavaVersion.VERSION_11 targetCompatibility JavaVersion.VERSION_11 } defaultConfig { minSdkVersion **MINSDKVERSION** targetSdkVersion **TARGETSDKVERSION** ndk { abiFilters **ABIFILTERS** } versionCode **VERSIONCODE** versionName '**VERSIONNAME**' consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD** } lintOptions { abortOnError false } aaptOptions { noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ') ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~" }**PACKAGING_OPTIONS** }**REPOSITORIES** **IL_CPP_BUILD_SETUP** **SOURCE_BUILD_SETUP** **EXTERNAL_SOURCES**
Warning
com.android.tools:r8:8.1.56 is required because the AAR was compiled using JDK 21+, which produces bytecode that causes older tools to fail during the DEXing step.
Unity Engine support for 16 KB memory page sizes (Android 15+)
To comply:
- Use Unity 2022.3.56
- Set Target API Level to 34 or higher
- If using Epic’s public project: Update Burst to "1.8.25"
Alternative Configuration for Unity 2021
Unity 2021 is supported as an alternative, but requires manual configuration of JDK and Gradle.
-
Install JDK 11 manually
Download from Oracle JDK 11 Archive
Then update gradleTemplate.properties with the path where you installed it, for example:
org.gradle.java.home=C:\\Program Files\\Java\\jdk-11. -
Upgrade Gradle to 7.5+
Download Gradle 7.5+ and set it in Edit → Preferences → External Tools.
If Unity keeps using Gradle 6.1:
-
Build once to generate the wrapper folder.
-
Open:
<project>\Library\Bee\Android\Prj\IL2CPP\Gradle\gradle\wrapper\gradle-wrapper.properties. -
Replace:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip. With:distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip. -
Update Build Tools
Move your Android SDK to a writable location (e.g. Documents\Android\SDK) and set this path under Preferences → External Tools.
If your project targets API 33 or higher, Unity should pull 33.0.2 automatically.
-
Clean Build Caches Delete:
C:\Users\<username>\.gradle
<your-project>\Library\Bee\Android
Alternative Configuration for Unity 6
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
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
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
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
Note
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.
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'
}
Warning
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
Note
The manifest file contains the line
You must replace its contents with the following version to ensure proper compatibility:
<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>
Manual Installation via SDK Manager (Command Line)
If Unity doesn’t auto-install it, you can do it manually:
-
Open Command Prompt and navigate to your Android SDK cmdline-tools folder.
For example:
cd C:\Users\<your-username>\Documents\Android\SDK\cmdline-tools\latest\bin.(If latest doesn’t exist, use the actual folder name inside cmdline-tools.)
-
Run the following command to install build-tools 33.0.2:
sdkmanager "build-tools;33.0.2". -
Accept the licenses if prompted by typing y and pressing Enter.
-
You can also verify the installation:
sdkmanager --list.You should see:
build-tools;33.0.2 | 33.0.2.
Manage Android SDK
It is possible that the SDK modules installed through Unity Hub would be missing components to build your game.
For example, Unity 2021.3.16 requires build-tool 33.0.2 to build the game but the tool is not included in the Unity Hub module installation.
The following methods will show how to install the missing build-tool 33.0.2, and give an idea how to manage SDKs.
Manage SDK with Android Studio (Recommended for better emulator support).
-
Run the SDK Manager
Manage SDK through command prompt
-
(On Windows) If you don't already have the environment variable
JAVA_HOMEas a System Variable, add a new one with the value set toC:\Program Files\Unity\Hub\Editor\2021.3.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK. -
Run the command prompt and navigate to the
SDK\tools\binfolder.On Windows:
cd 'C:\Program Files\Unity\Hub\Editor\2021.3.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\bin'For most *nix:
../Unity/Hub/Editor/2020.1.11f1/Editor/Data/PlaybackEngines/AndroidPlayer/SDK/tools/bin -
Run
On Windows:
.\sdkmanager.bat "platform-tools" "platforms;android-30" "build-tools;33.0.2"For most *nix:
sdkmanager "platform-tools" "platforms;android-33" "build-tools;33.0.2"
External Module Setup
Modules can be shared across multiple versions of Unity on the same device by specifying the shared install path in Edit -> Preference -> External Tools