ERROR: Build Failed: Error code: 256

Hi there everybody
Everything worked well on my iMac until Corona SDK evolved into Solar 2D.
What does this mean? This mean that I was able to build my apps for my Android devices and test them on real hardware.
As you can read in the title of this topic I can’t do it anymore due to that error.
When I try to build a project, in the building pane I can also read:
WARNING: Java 1.8 does not seems to be available. If build fails, install Java 1.8.

Building actually fails…

So I updated Java via OSX control panel and now the control panel recognizes the Java latest version 8 and Java build 1.8.0_251-b08;
but if I type “java -version” via terminal, the following message is displayed:
Java™ SE Runtime Environment (build 1.6.0_65-b14-468-11M4833)

What can I do? Is there a way to install Java via terminal?

Thanks in advance.

@Simone1973 - I have both the OFFLINE (3598+) and ONLINE (3583) versions working fine on my Mac. Java version 8 is a must. Why install Java via terminal?

Thanks for your reply :slight_smile:
The picture you linked is actually identical to what I can see when I open MY Java control panel.
I don’t know why I cannot build projects as I used to do before Corona evolved into Solar 2D.
But:

  • the command java -version in my terminal returns 1.6 and the solar 2d builder tells me I need java 1.8
  • Java 8 Update 251 is installed on my mac

Everything should work fine but it doesn’t.
After I opened this discussion I downloaded and installed the whole JDK package. Now the java version via terminal is 14.0.1+7; worse or better than before? I don’t know.
But everything is still not working fine.
One last thing.
At the moment I’m working with the Solar 2D 3598 version.

TMAC:~ troylyndon$ java -version
java version “1.8.0_111”
Java™ SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot™ 64-Bit Server VM (build 25.111-b14, mixed mode)
TMAC:~ troylyndon$

Thanks again; I understood everything works fine with you…

This is my terminal:

iMac:~ admin$ /usr/libexec/java_home -V
Matching Java Virtual Machines (3):
    14.0.1, x86_64:	"Java SE 14.0.1"	/Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home
    1.6.0_65-b14-468, x86_64:	"Java SE 6"	/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    1.6.0_65-b14-468, i386:	"Java SE 6"	/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

As you can see, version 1.6 is still present and I still don’t know how to replace it with 1.8.

This is how the end of the compiling process appears when the error occurs:

FAILURE: Build failed with an exception.
                    
                    * What went wrong:
                    Could not initialize class org.codehaus.groovy.reflection.ReflectionCache
                    
                    * Try:
                    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
                    
                    * Get more help at https://help.gradle.org
                    
                    BUILD FAILED in 7s
giu 05 18:20:55.787 Android build failed (256) after 12 seconds
giu 05 18:20:56.002 ERROR: Build Failed: Error code: 256

@Simone1973 - is it important to be running 3 Java Virtual Machines? If not, I’d recommend you…

  1. remove all virtual machines
  2. uninstall java
  3. install java version 8 (which from terminal appears as 1.8)

Thank you again for waisting your time with such a strange issue.
I uninstalled Java and all its old virtual machines via terminal commands, following the uninstall instructions in the official page.

When I tryied to build my project it said something like this (as expected…):

giu 06 16:51:09.271 Unable to find any JVMs matching version "(null)".
giu 06 16:51:09.292 No Java runtime present, requesting install.
giu 06 16:56:17.468 Corona Simulator: Java is required by the Android SDK and needs to be installed to build Android applications.
                    
                    You have the Java Runtime Environment (JRE) installed but Android builds require the Java Development Kit (JDK).  Be sure to install the right package.

then I re-installed this:
jre-8u251-macosx-x64.dmg

It reinstalled Java and java control pane. The builder - obviously - continued giving me the same alert.
So I installed this:
jdk-14.0.1_osx-x64_bin.dmg
and the WARNING: Java 1.8 does not seems to be available. If build fails, install Java 1.8. appeared again…
That’s because jdk-14 installs a virtual machine but it doesn’t include the java 1.8 virtual machine that I (really) need.

In the oracle official site, everything containing “8” in its name, requires to log in to be downloaded.
I don’t have an oracle account and I think you don’t need to have one to develop in Solar 2D.

Since you are so kind, have you got a link to share?

You can take a look at that discussion on GitHub - https://gist.github.com/wavezhang/ba8425f24a968ec9b2a8619d7c2d86a6

1 Like

Ok
The 99% of the links/methods in the discussion you kindly linked don’t work anymore.
The only one that worked is the following:

https://mirrors.huaweicloud.com/java/jdk/

From there I downloaded this:
jdk-8u151-macosx-x64.dmg

Now via terminal, the command /usr/libexec/java_home -V returns:

iMac:~ admin$ /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
    14.0.1, x86_64:	"Java SE 14.0.1"	/Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home
    1.8.0_151, x86_64:	"Java SE 8"	/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home

My mac recognizes the 1.8 version.

I tryied to build again my project and it reacted as follow:

giu 06 21:12:55.965 Using java version "14.0.1" 2020-04-14
                    Java(TM) SE Runtime Environment (build 14.0.1+7)
                    Java HotSpot(TM) 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)
giu 06 21:13:00.555 BUILD SUCCESSFUL
                    Total time: 3 seconds
giu 06 21:13:47.865 Excluding specified files from build: 
                       excluding: LaunchScreen.storyboardc
                       excluding: Icon.png
                       excluding: Icon-*dpi.png
                       excluding: Images.xcassets
                    Android build succeeded in 51 seconds

A little bit slow imho; with corona SDK it needed 30 seconds to build but this is way better than none.

So apparently it works and we could set the topic SOLVED.

But I noticed that the file extension isn’t .APK anymore but .AAB
Will it work on real devices? I’m going to test soon.
Stay tuned…

It should create both APK and AAB. The AAB is the 64-bit requirement set for uploading to Google, whereas the APK can be used to install on your device locally using ADB (Android Debugging Bridge).

1 Like

YES!

Since there already was a copy of the APK project in the folder, I saw only the new one that the builder created, that is the one with the .AAB extension.
But as you said, the builder at the moment actually generates two files.

Thank you both SO much!

I hope you precious suggestions could help those who are stuck in such a “strange” issue…

SOLVED