Just tried out Unity 6.0 and surprisingly, upgrading the Unity version didn’t completely break down things! Managed to get the iOS build working on device!
However, didn’t get the same success with Android build!
On building the android platform, build fails with following grade error:
What went wrong:
A problem occurred evaluating project ‘:launcher’.
Failed to apply plugin ‘com.android.internal.application’.
The option ‘android.enableDexingArtifactTransform’ is deprecated.
The current default is ‘true’.
It was removed in version 8.3 of the Android Gradle plugin.
If you run into issues with dexing transforms, try setting android.useFullClasspathForDexingTransform = true instead.
Apparently the Unity 6 uses gradle 8.4 and it seems to be not compatible with certain package. I tried the recommendation in the error message without any luck. Wonder if manually downgrading the gradle could solve the issue?
Not able to use Android Resolver either in Unity 6.
Starting a Gradle Daemon (subsequent builds will be faster)java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7
To everyone, this indeed is a very simple problem to fix for the Unity Team.
check update below for easier solution
I actually managed to make it work by Exporting Android Project instead of making an Android Build. And, then going to the gradle file, and manually fixing by making the change as written in the error message.
There is a line android.enableDexing… that needs to be disabled. Then, you insert another line instead of that android.useFullClasspath… (See the error log in my first post to see the exact lines without any spelling mistake).
You can actually create a PostBuild Script to automate this every time you export an android project. Then, you need to install Android Studio and I can confirm that I was able to build apk file with android studio from the exported project.
In fact, Unity also uses Android NDK to build your project after the first step of building android project. Just in an automated way so we don’t have this additional trouble. But, good thing is that the two manual build steps (unity then Android Studio) is actually quite fast…
All that Unity Team needs to do is to incorporate these changes when building the android project and before running the android NDK on it.
Hope that helps.
UPDATE:
There is an easier way to do the above without exporting Android Project. In Project Settings, enable custom gradle template. then, you will find a gradleTemplate.properties file in your Assets/Plugins/Android folder.
You can just add this line in this file: android.useFullClasspathForDexingTransform=true
Unity is not adding enableDexingArtifactTransform, the issue might be caused by a third-party plugin and EDM4U. Could you please share with us which plugins are you using so that we can report it to the developer?
I assume you tried adding android.useFullClasspathForDexingTransform = true to the gradle.properties file as it recommends, am I right?
Finally fixed the issue for my case. I had it since yesterday, and no matter what I did I couldn’t get it to build for Android. Clean Library completely, remove and install IAP and a few other possible assets, changed the line that’s given in the error report, but it would always get overridden.
In the end I found that the deprecated code is called in another 4 places aside form the gradleTemplate.properties
So I changed it all from android.enableDexingArtifactTransform=false
to android.useFullClasspathForDexingTransform=true