Gradle build issues with 5.5f1

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?

I just stumbled across this page: Unity - Manual: Gradle troubleshooting

Looks like my 1st issue may be a known one, not sure its a bug then…

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 :slight_smile:

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 !

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:

  buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    dexOptions {
        javaMaxHeapSize "2g"
    }

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):

org.gradle.daemon=true
GRADLE_OPTS="-Xmx4096m -Xms4096m -XX:MaxPermSize=2048m"
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.configureondemand=true

The exported Unity project I think includes a starting proguard rules file that maybe good to start with.

Good luck :slight_smile:

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?

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 :slight_smile:

I’m not suggesting making your own gradle.build, just modifying it as required to get things to work.