Hi,
I need help getting Unity cloud build to work with Android. We are using ProGuard minify with our local builds to make it work because without it we hit the 64k method DEX limit and the build fails.
Unfortunately I did not find any way to enable ProGuard minify in Unity cloud builds. Does anyone know how to do that (using Unity 2019 LTS)?
Custom Gradle Template?!
I found one “solution” which includes using a custom gradle template and adding instructions to enable ProGuard minify. Unfortunately I don’t manage to get a working build with a custom gradle templete and the documentation is super outdated (Unity - Manual: Gradle for Android). There are much more Gradle checkboxes and I don’t know which one to use and in what way exactly I have to modify my template
I talked to the Unity Support.
There are two approaches to solve this issue:
A) Increase Minimum API Level
- Go to Android Player Settings
- Change “Minimum API Level” to "Android 5.0 ‘Lollipop’ (API level 21)
Higher Android API levels do not have the 64k DEX Limit or use Multidexing or something like that so you won’t run into DEX issues anymore. Drawback: That approach may exclude people with very old devices from your app.
B) Custom Launcher Gradle Template
- Go to Android Player Settings
- Enable the Checkbox “Custom Launcher Gradle Template”
- Save the project
- Edit the file “Assets/Plugins/Android/launcherTemplate.gradle” to look like this:
...
buildTypes {
debug {
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt')**SIGNCONFIG**
jniDebuggable true
}
release {
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt')**SIGNCONFIG**
}
}**PACKAGING_OPTIONS****SPLITS**
...
In other words: make sure that minifyEnabled and useProguard are both set to true for debug and release builds.
Both approaches worked for me and allowed me to make Cloud Builds.
Approach B is slightly more work but you don’t have to change your min API level that way.
1 Like