Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Using Gradle Build System with Cloud Build

Discussion in 'Unity Build Automation' started by pokersquare, Jan 31, 2017.

  1. pokersquare

    pokersquare

    Joined:
    Nov 7, 2016
    Posts:
    4
    Hi,

    We have a project and we were exceeding 65K method limit on Android, so we decided so set Gradle as Build System which sorted out the 65K limit issue.

    When the project is getting build on Unity Cloud Build i think it is not using the gradle build system. Can somebody help in how to setup Gradle Build System for Cloud Build.
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    I don't think this is currently supported.
     
  3. pokersquare

    pokersquare

    Joined:
    Nov 7, 2016
    Posts:
    4
    @liortal Any idea when its coming out
     
  4. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    785
    Unity Cloud Build does not support gradle builds currently, and no immediate plans to support it.
     
  5. MechEthan

    MechEthan

    Joined:
    Mar 23, 2016
    Posts:
    166
    I'm confused, what does this FAQ item about Gradle refer to then?

    https://developer.cloud.unity3d.com/support/faq/

    Which build methods does Unity Cloud Build support for native Android projects?
    Unity Cloud Build supports Ant and Android Studio/Gradle projects at this time.

    Does this mean we can't use Unity's Gradle build system directly on UCB, but we can use "Export Project" to produce a Gradle Android project that we then upload and have UCB build?
     
  6. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    785
    Sorry for the confusion. That FAQ is apparently very out of date (and I'll look into cleaning it up). We never supported building a gradle project exported from Unity, although at one point way back in our history we had limited support for building native android gradle projects (which has since been completely removed).
     
  7. Adam-VisualVocal

    Adam-VisualVocal

    Joined:
    Sep 22, 2016
    Posts:
    10
    Gradle seems to be available now as a Cloud Build option for Android. I gave it a try but it's up to 30 minutes of wait time now and counting. Is the Gradle option really a thing now or is it not really ready for prime time yet? Thanks.
     
    Last edited: Mar 31, 2017
  8. Adam-VisualVocal

    Adam-VisualVocal

    Joined:
    Sep 22, 2016
    Posts:
    10
    The Gradle build did eventually execute (after 31 minutes) and it seemed to work. Great! Has there been any official announcement about Gradle being available in Cloud Build?
     
  9. SophiaC

    SophiaC

    Joined:
    Sep 6, 2016
    Posts:
    238
  10. Adam-VisualVocal

    Adam-VisualVocal

    Joined:
    Sep 22, 2016
    Posts:
    10
    Fantastic! Thank you Sophia.
     
  11. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    How do i define gradle for our build ? can't find that option.
     
  12. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    785
    @liortal: it's under the advanced options for the build target (listed as "Android Build System").
     
    Marc-Uberstein likes this.
  13. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Totally missed it. it's not in the summary, only when you click edit:

    upload_2017-4-27_16-32-9.png
     
    eamengual likes this.
  14. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    785
    Ya, that was overlooked (it will show up there once set, but not initially). We'll get it cleaned up soon.
     
  15. Qbit86

    Qbit86

    Joined:
    Sep 2, 2013
    Posts:
    487
    @dannyd I've switched to Gradle build option, specified `mainTemplate.gradle` and `proguard-user.txt`, specified Minify option as Proguard. But. I have no idea where these settings are persisted, so which files I need to commit and push so that our build machine could build the project. I don't see any of these settings appeared in ProjectSettings.asset.
     
  16. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    These are saved to your ProjectSettings.asset file.
     
  17. Qbit86

    Qbit86

    Joined:
    Sep 2, 2013
    Posts:
    487
    I've set serialization mode as Force text, so I could preview changes in Git client. I see no evidence of four settings in ProjectSettings.asset:
    • Build System: Gradle (New)
    • Custom Gradle Template: true
    • User Proguard File: true
    • Minify: Proguard
     
  18. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    My bad, it appears these are not stored in project settings for some reason. when i switch my "custom gradle template" to off, it seems to just rename the file to mainTemplate.gradle.DISABLED. kind of a weird hack.. not sure why it was implemented this way :)
     
    Qbit86 likes this.
  19. Qbit86

    Qbit86

    Joined:
    Sep 2, 2013
    Posts:
    487
    @dannyd @Yury-Habets Could you please fix this and implement as ordinary YAML-settings?
     
  20. Qbit86

    Qbit86

    Joined:
    Sep 2, 2013
    Posts:
    487
    Well, if it is not renamed, then it is still not enough for build server to use Gradle...

    @dannyd @Yury-Habets Where this setting is stored?
     
  21. Qbit86

    Qbit86

    Joined:
    Sep 2, 2013
    Posts:
    487
    @dannyd @Yury-Habets At least: is there any way to specify Gradle option as command line argument? Please let me know.
     
  22. Anatolii_Landyshev

    Anatolii_Landyshev

    Joined:
    Aug 10, 2012
    Posts:
    31
    Hi all.

    I'm trying to setup Cloud Build for Android project using Gradle.
    When building locally I turn ProGuard off since it causes some issues.
    But cannot find how to turn it off in Cloud Build.
    On Cloud Build I get same issues as if ProGuard is on.

    Could you advice anything?
    Thanks.
     
  23. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    @alandyshev Interestingly enough I'm having issues getting Proguard minify to actually work in CB, and I'm hitting the 65k dex limit as a result (works fine locally)... As far as I know there's no setting for it on the dashboard, and I'm not sure it even reads the settings from player settings
     
  24. jcion

    jcion

    Joined:
    Jan 24, 2015
    Posts:
    7
    Having issues as well. I would like to enable Custom Gradle Template and User Proguard File in Cloud Build, but I can't seem to find the settings for it. The changes don't seem to appear in ProjectSettings.asset
     
  25. sam_ettinger_sm

    sam_ettinger_sm

    Joined:
    Dec 1, 2016
    Posts:
    19
    Bumping this. Has anyone figured out where Unity stores the Minify player settings? And how to save those settings in source-control so UCB can find them?
     
    Qbit86 likes this.
  26. Wanderer13

    Wanderer13

    Joined:
    Feb 11, 2016
    Posts:
    19
    For UCB you can use custom gradle template. There is settings to minify at the end of this file. I totally disabled both (minifyEnabled false, useProguard false).

    **SIGN**
    buildTypes {
    debug {
    minifyEnabled false
    useProguard false
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD**
    jniDebuggable true
    }
    release {
    minifyEnabled false
    useProguard false
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD**
    **SIGNCONFIG**
    }
    }

    }
     

    Attached Files:

  27. Deleted User

    Deleted User

    Guest

    I also need to know this. I'd like to turn gradle builds off on our automated build system but I can't find where this is set
     
  28. PSchaussPlaya

    PSchaussPlaya

    Joined:
    Mar 2, 2018
    Posts:
    14
    If found this regarding Proguard Minify
    https://stackoverflow.com/questions/49398444/how-to-verify-that-proguard-is-enabled-in-unity-build

    So I guess you can put this in a Pre-Build Script to enforce Proguard Minify (did not test it yet):
    Code (CSharp):
    1. EditorUserBuildSettings.androidReleaseMinification = AndroidMinification.Proguard;
    I could not find EditorUserBuildSettings.androidReleaseMinification in the documentation. Only the enum is listed there.

    I also think that this setting is not properly serialized - at least not within the project itself. Because we work in a team and when we check out the project people have to manually enable minify first. So it's maybe a global editor setting and not a project setting?

    This should definitely be changed by Unity. All relevant build settings should be serialized within the project files otherwise it leads to annoying issues.

    Edit:
    Okay, this setting seems to have no effect and does NOT fix the issue with cloudbuilds
     
    Last edited: Aug 7, 2020
    guneyozsan likes this.