gradle build error when update from 5.6.4p4 to 2017.3.1f1
i got this error when trying to build now on 2017.3.1f1 i have no clue about it, if someone has a problem similar and could help , would be great
CommandInvokationFailure: Gradle build failed.
/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/java -classpath "/Applications/Unity/PlaybackEngines/AndroidPlayer/Tools/gradle/lib/gradle-launcher-4.0.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx2048m" "assembleDebug"
stderr[
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/hernanzambrano-astete/Workspace/Unity/thomasandfriends-raceon/Temp/gradleOut/build.gradle'
* What went wrong:
Could not compile build file '/Users/hernanzambrano-astete/Workspace/Unity/thomasandfriends-raceon/Temp/gradleOut/build.gradle'.
> startup failed:
General error during class generation: 956
java.lang.ArrayIndexOutOfBoundsException: 956
at org.codehaus.groovy.classgen.asm.CallSiteWriter.getCreateArraySignature(CallSiteWriter.java:58)
at org.codehaus.groovy.classgen.asm.CallSiteWriter.makeCallSite(CallSiteWriter.java:317)
Answer by Ciryus · Apr 12, 2018 at 11:47 AM
Actually in my case it seems to be related to StreamingAssets that are added in the aaptOptions one by one, overstepping the 250 elements limit in the array.
I've found the same. Were you able to move beyond this point? As Nuaro mentioned above, I've also found this issue to not occur in Unity 5.6.5.
Unfortunately there is no solution with building in gradle. You could give a try with an internal build, or may be exporting your project with gradle and build it in Android Studio. You could also consider using Asset Bundles ins$$anonymous$$d of Strea$$anonymous$$gAssets.
That is definitely unfortunate. Cannot do an internal build without going beyond the DEX limit. Nor can I make a gradle build in 5.6.5 because even though this problem does not occur, we get another one about duplicate BuildConfig files. It's like 2017.4.1 and 5.6.5 simply traded errors.
How did you come to this conclusion? I unfamiliar with and can't seem to find much info on aaptOptions and how it might interact with Strea$$anonymous$$gAssets. I accept it, just would like to be a bit more in the know :)
Answer by Artistic · Mar 15, 2018 at 07:48 AM
If it helps someone, when i use "Split Application Binary" (APK + OBB), error is go away..
ok the problem is for some reason now Unity add on the build.gradle file all the resources on the aaptOptions, now the problem if you have more than 250 element there, its going to fail because for "reasons" the method org.codehaus.groovy.runtime.ArrayUtil.createArray only create arrays with 250 elements, the way to fix it is split the aaptoption with only 250 elements, that is too the reason when you split the binary works fine.
the thing is I don't know the reason why unity do this, on 5.6 this doesn't occurs.
i hope this help someone, and anyone can give a reason or a way to fix this.
thanks all for the answers
I have run into this same problem when building for Amazon since we cannot use an OBB file. WHat I did to get around this is to use the custom gradle file option in build settings, and then in the aaptOptions section, remove the STREA$$anonymous$$ING_ASSETS text and add in wild card file extensions of all your assets. Why Unity can't do wild card listing like the default ones ins$$anonymous$$d of listing every file is beyond me.
Seems like we could come up with a process script to deter$$anonymous$$e the unique file extensions and then replace the long file listing with just the extensions required. Unfortunately i haven't had time to look into that yet.
Answer by ikhsaniks · Mar 14, 2018 at 03:51 PM
Hi @Nuaro In Unity version of 2017 or later, only compatible with SDK 25.2.5 and JDK 1.8.161 (I think). So change your SDK -> Tools with 25.2.5 version. If you don't want to overwrite your tools folder you can rename it to something else. Here is my SDK and JDK you can download and add it to the Unity -> Preferences -> External Build https://drive.google.com/drive/folders/16n3hvR9JfTaKWW0MGNDhHLc6XIg3agM9?usp=sharing
hope it works on you. Insya Allah. Regards, Ikhsan Syahputra.
Answer by Nuaro · Mar 14, 2018 at 05:25 PM
Thanks @ikhsaniks for the help, but i'm still getting the same error, if you have any other idea of what i could try i really appreciate. by the way i'm working on a OSX(Mac)
if in something helps, when i remove the resources folder from the unity project , the build is created, and i don't get the error, that makes the issue more weird
I'm getting the same error. Have you sovled it finally?
Answer by Durston88 · Dec 10, 2018 at 06:42 PM
@linlinsky Apologies, I never updated this thread. I do believe I figured this out a few weeks after I last posted here. Though it's not fresh in my mind, I do have some brief notes on it, which follow:
Looking at the mainTemplate.gradle file in the Unity 5.6.5 project, I don't have a STREAMING_ASSETS flag in it anymore, and it is simply:To get around the ArrayIndexOutOfBounds issues, I had to go into the custom mainTemplate.gradle file and change STREAMING_ASSETS to manually list out the wild carded filetypes contained in that folder (like “.hd”, “.sd”, “.manifest”)
aaptOptions {
noCompress '.unity3d', '.ress', '.resource', '.obb'
}
As mentioned I had another issue in 5.6.5 with duplicate BuildConfig files within plugins, and I'd discovered the fix to that at the same time:
To get around the duplicate BuildConfig issues, I manually went into the .jar files for the offending plugins - SwrveSDKPushSupport, SwrveSDKUnityBridge, and Notifications… opened it up as a zip file and simply deleted the BuildConfig file therein. Also had to make sure any created .meta files got deleted before re zipping back into a .jar file.
Hope this is helpful!