Search Unity

How to gradle build?

Discussion in 'Android' started by Kalle-Cederstrom, Mar 29, 2017.

  1. Kalle-Cederstrom

    Kalle-Cederstrom

    Joined:
    Jan 22, 2014
    Posts:
    6
    So our plugins run out of those 64K functions in DEX build, and now I try my hands on the gradle building but I thinks I'm missing some fundamental information how to do that.

    Can someone please give me a step by step instructions how to make a build from editor to phone using gradle?

    Environment:
    OS X 10.11.6
    Unity 5.5.2p3
    javac 1.8.0_102
    Android Studio 2.3
    Android SDK Tools 25.2.5
    Android SDK Platform-tools 25.0.4
    Android SDK Build-tools 25.0.2
    Android 7.1.1 (API 25)
    Android Support Repository 47
    Google Play services 39
    Google Repository 45

    Steps I managed to take this far:
    1. Made a project
    2. Installed too many plugins on it for Dalvik build
    3. Followed instructions from https://docs.unity3d.com/Manual/android-gradle-overview.html
    4. Ran in the problems even with that
    5. Followed instructions to export the project.
    6. Installed gradle-3.4.1
    7. Added it to /etc/paths
    8. Ran gradle in the exported folder (where the build.gradle is) and got a following:

    Starting a Gradle Daemon (subsequent builds will be faster)

    FAILURE: Build failed with an exception.

    * Where:
    Build file '/Users/username/Desktop/Projects/android_test/Project01/build.gradle' line: 20

    * What went wrong:
    A problem occurred evaluating root project 'Project01'.
    > Failed to apply plugin [id 'com.android.application']
    > Gradle version 2.10 is required. Current version is 3.4.1. If using the gradle wrapper, try editing the distributionUrl in /Users/username/Desktop/Projects/android_test/Project01/gradle/wrapper/gradle-wrapper.properties to gradle-2.10-all.zip

    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

    BUILD FAILED

    Total time: 3.493 secs


    So what did I do wrong and what I am missing?
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Starting with Unity 5.5, you can export your Android game using Gradle (which comes installed with the Unity editor).

    I suggest you gave that a try.
     
  3. Kalle-Cederstrom

    Kalle-Cederstrom

    Joined:
    Jan 22, 2014
    Posts:
    6
    I did that in step 5, then what?
     
  4. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    You shouldn't run gradle from the command line; you should select "Gradle" as the build system inside Unity and let it run the build. If you run into issues, feel free to contact me via this link.