Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to change the gradle.properties file in Unity

Unity has a default gradle.properties file that gets added during the build process. While its possible to change the build.gradle and the settings.gradle files as mentioned here https://docs.unity3d.com/Manual/android-gradle-overview.html there is no mention of being able to change gradle.properties within the unity docs. The file also gets recreated every build attempt so editing it within the temp/gradleOut after a build and building again doesn't work. I know exporting the project is possible as well, but I'm looking for a solution where the project can be run directly from unity.

Btw this question is NOT a duplicate of this question How to use Gradle in Unity The answer here has nothing to do with modifying the gradle.properties file.

This is a duplicate of this question that got incorrectly marked as a duplicate how to change default gradle.properties of Unity?

like image 454
ChristianToMidiOut Avatar asked Jan 14 '19 17:01

ChristianToMidiOut


People also ask

How do I change Gradle in Unity?

Go to Build Settings > Android, and set Build System to Gradle to use the custom Gradle version. Go to Preferences > External Tools > Android > Gradle Installed with Unity. Clear the option, and specify a custom version of 5.6. 4 or later.

Where is Gradle properties file in Unity?

The project properties file resides at: <LABKEY_HOME>/gradle. properties.


1 Answers

Maybe my answer is a bit outdated but in Unity 2020 you can do it in:

Player Settings -> Tab Android (with robot obviously) -> Publishing Settings -> Custom Gradle Properties Template (checkbox).

After enabling the checkbox you will see the path to gradleTemplate.properties (usually it appears in Assets/Plugins/Android directory) file which will be merged with final gradle.properties.

Everything you need you can write to the end of file after **ADDITIONAL_PROPERTIES** string.

Example:

org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
org.gradle.parallel=true
android.enableR8=**MINIFY_WITH_R_EIGHT**
**ADDITIONAL_PROPERTIES**

android.useAndroidX = true // I added this property to fix error:  This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry.

Also on screenshot:

How to modify gradle.properties file in Unity

like image 76
Sergey Pekar Avatar answered Sep 30 '22 09:09

Sergey Pekar