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

Best practice for Gradle builds in Android Studio?

Discussion in 'Android' started by waldgeist, Jun 28, 2019.

  1. waldgeist

    waldgeist

    Joined:
    May 6, 2017
    Posts:
    386
    I'm a bit confused about the recommended way to handle Gradle builds in Android Studio. Somewhere in the Unity docs I found the info, that you should not use the standard Gradle version included in Android Studio, but instead use the one shipped with Unity itself, as part of its application folder.

    If I do this, builds work, but Android Studio keeps complaining that this version is outdated and I should better upgrade everything. I also need to include some OpenSource Android packages that require specific Gradle versions, like 4.3 and higher.

    My questions are:
    - What is the background behind Unity requiring their own Gradle version?
    - Are the Unity docs even up to date, or could you just use Gradle as provided by Android Studio nowadays? I tried it, and it worked, but I am unsure about it.
    - I plan to compile the custom Android code into Unity Android plugins, so the plugins would have their own Gradle build process. Could I at least use the more recent Gradle version for this, and then later build the actual Unity app with the Gradle version shipped by Unity?
    - What's the general "best practice" when building Unity apps directly from within Android Studio?

    Thanks in advance for any feedback.