To have some control over the format and contents of Gradle project files, you can override Unity’s default templates with your own custom template. To do this:
To verify that your template modifications give the result that you expect, export your project and view the final Gradle project files in the resulting project.
You can use the following variables in custom Gradle template files:
可变 | 描述 |
---|---|
DEPS | The list of project dependencies. This is the list of libraries that the project uses. |
APIVERSION | The API version to build for. Unity sets the and TARGETSDKVERSION to the same value (Target API Level in the Android Player Settings). |
MINSDKVERSION | The minimum API version that supports the application. |
BUILDTOOLS | The SDK build tools to use. |
TARGETSDKVERSION | The API version to target. Unity sets the and APIVERSION to the same value (Target API Level in the Android Player Settings). |
APPLICATIONID | Android Application ID. For example, com.mycompany.myapp. |
MINIFY_DEBUG | Indicates whether to minify debug builds. |
PROGUARD_DEBUG | Indicates whether to use ProGuard for minification in debug builds. |
MINIFY_RELEASE | Indicates whether to minify release builds. |
PROGUARD_RELEASE | Indicates whether to use ProGuard for minification in release builds. |
USER_PROGUARD | Specifies a custom ProGuard file to use for minification. |
SIGN | Complete the signingConfigs section if this build is signed. |
SIGNCONFIG | Indicates whether the build is signed. If this property is set to signingConfig.release , the build is signed. |
DIR_GRADLEPROJECT | Unity 创建 Gradle 项目的目录。 |
DIR_UNITYPROJECT | The directory of your Unity project. |
PLAY_ASSET_PACKS | Specifies the asset packs to include in your application. |
BUILTIN_NOCOMPRESS | Specifies a default list of files extensions to not compress. The file extensions are: .unity3d , .ress , .resource , .obb , .bundle , .unityexp . |
Custom settingsTemplate.gradle
files can also contain the following variables:
可变 | 描述 |
---|---|
INCLUDES | The list of Android Library plug-ins to include in the Gradle project. |
Custom gradleTemplate.properties
files can also contain the following variables:
可变 | 描述 |
---|---|
JVM_HEAP_SIZE | The maximum size of the Java virtual machine (JVM) heap. |
STREAMING_ASSETS | The list of files in the Steaming Assets folder that Gradle shouldn’t compress. |
ADDITIONAL_PROPERTIES | Contains additional properties for the application. This includes: • The Gradle template version. • The path to the Unity project. • If the application uses the Android App Bundle publishing format, a flag that indicates to keep native libraries compressed. • If the application uses the GameActivity application entry point, a flag that indicates to use AndroidX. |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.