Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Gradle build issues with 5.5f1

Discussion in '5.5 Beta' started by liortal, Nov 24, 2016.

  1. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Just wanted to update that i've opened 2 bugs related to Gradle builds:

    (Case 854494) Android build fails with Gradle build system
    (Case 854492) Duplicate error message on Android build failure

    Is this an experimental feature or should this be fully working in 5.5 official release?
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
  3. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    EDIT:

    Added these 2:
    (Case 854533) Android gradle build fails when including .jar with AndroidManifest.xml inside
    (Case 854535) Can't build with Gradle and resources under Plugins/Android/res

    Please have a look :)

    We are currently hitting the dex 65k issue, really counting on upgrading to 5.5 + gradle (and proguard) to solve this kind of issue for us for our next release !
     
  4. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    I've solved this by using the minifyEnabled options and some other tweaks to get things working:

    In the android {} block of your gradle.build add:

    Code (csharp):
    1.   buildTypes {
    2.         release {
    3.             minifyEnabled true
    4.             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    5.         }
    6.     }
    7.  
    8.     dexOptions {
    9.         javaMaxHeapSize "2g"
    10.     }
    Create a proguard-rules.txt file that excludes the required packages, etc.

    I also needed to create a gradle.properties file (in the same folder as the gradle.build file) with the following content (or it would fail to minify):

    Code (csharp):
    1. org.gradle.daemon=true
    2. GRADLE_OPTS="-Xmx4096m -Xms4096m -XX:MaxPermSize=2048m"
    3. org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
    4. org.gradle.parallel=true
    5. org.gradle.configureondemand=true
    The exported Unity project I think includes a starting proguard rules file that maybe good to start with.

    Good luck :)
     
  5. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    I could do that... But since 5.5 now supports gradle, i think it should just work out of the box, without creating my own build.gradle.

    BTW how are you using gradle with 5.4?
     
  6. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    In 5.4 you export and Android project (Eclipse style) and Android Studio has support for importing Eclipse projects - it converts everything to a gradle project.

    To support third party SDKs I'd assume you'll likely need to do some tweaks to your gradle.build. This is just an assumption, but my experience so far leads me to believe this :)

    I'm not suggesting making your own gradle.build, just modifying it as required to get things to work.
     
    Last edited: Nov 25, 2016