JDK 6 needed for Android Builds?

Google’s newest Android SDK and their recently released Android Studio supports both JDK 6 and 7.  So, yes, it is now safe to install JDK 7.  But note that Google’s system requirements for Mac still requires the JRE 6.

   http://developer.android.com/sdk/index.html#Requirements

On Windows, you can easily install both JDK/JRE 6 and 7 on the same machine.  I’ve never tried to install separate versions of Java on Mac before.  So, you’re on your own there.

Hi, I’ve similar problem

This is my environment

Mac iOS: 10.10.5 Corona: Build: 2015.2785 Java 6 (default)  -java version "1.6.0\_65"  -Java(TM) SE Runtime Environment (build 1.6.0\_65-b14-468-11M4828a)  -Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-468, mixed mode) Java 7  -Using java version "1.7.0\_72"  -Java(TM) SE Runtime Environment (build 1.7.0\_72-b14)  -Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode)

I’ve created a signed certificate with keytool from comand line, using default java (6).

When build with signed certificates in the Corona Console I see:

Using java version "1.7.0\_72" Java(TM) SE Runtime Environment (build 1.7.0\_72-b14) Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode) Picked up JAVA\_TOOL\_OPTIONS: -Duser.language=en Picked up JAVA\_TOOL\_OPTIONS: -Duser.language=en jar signed.

First ask: why Corona use Java 7???

But the problem is that some device (4.0.1 or 2.3.3) cannot installa apk (from Google Play), the user see this error:

Package file was not signed correctly

Where is the problem? The Java version used by Corona for signed apk? How to change Java for Corona?

Thank you!

The JDK is needed to do Android APK builds and for digital signing.  The same is true for native Android development as well.

Since your Android device is refusing to install your APK due to a signing error, that means their is something wrong with the keystore file that you’ve created.  You need to create a keystore file according to Google’s instructions (link below) at the command line.  You only need to do step 1 in these instructions.  Once the file is created, reference it the Corona Simulator’s build window.

   http://developer.android.com/tools/publishing/app-signing.html#signing-manually

I try but does not works!

The error (during installation) is:

java.lang.SecurityException: META-INF/XXXX.SF has invalid digest for assets/....

The problem seems similar to this post:

https://forums.coronalabs.com/topic/52593-app-does-not-install-on-android-device-certificate-error-invalid-digest-corona-asset-widget-theme/

But I don want disinstalled Java 7

And I think the Corona use Java 7 while building from this message on console?:

Dec 16 11:37:53.185 Using java version "1.7.0\_72" Java(TM) SE Runtime Environment (build 1.7.0\_72-b14) Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode) Dec 16 11:37:55.106 Building android app for user with 2015.2785 Dec 16 11:37:58.729 Using custom build id from app bundle: 00000 (AppSettings.lua) Dec 16 11:37:59.692 BUILD SUCCESSFUL

Thank you!

I try to to sign apk manualy with jarsigner (using Java 6) and I can install apk on device with success!

So, the problem seems that corona use Java 7 when sing apk, and in same device (4.1.1, 2.3.3) the signature doesn’t work.

How can tell to Corona to use JAVA 6, without disinstalled JAVA 7?

I can sign manually but I cannot use zipalign without unaligned apk.

The Windows version of the Corona Simulator supports JDK 6, 7, and 8.  All of these JDK versions will correctly digitally sign the APK.  My Windows OS environment has multiple JDK installed as well and it works.

Are you running the OS X version of the Corona Simulator?

Also, which Corona build # are your running?

(The more info you can provide us, the faster this will go.)

This my environment:

Mac iOS: 10.10.5 Corona: Build: 2015.2785 Java 6 (default) -java version "1.6.0\_65" -Java(TM) SE Runtime Environment (build 1.6.0\_65-b14-468-11M4828a) -Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-468, mixed mode) Java 7 -Using java version "1.7.0\_72" -Java(TM) SE Runtime Environment (build 1.7.0\_72-b14) -Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode)

I worked for help you to investigate the problem. In the below link (drop box) there are keystore and all apks.

I’ve created a new certificate (for_corona.keystore) with this command:

keytool -genkey -v -keystore for\_corona.keystore -alias for\_corona -keyalg RSA -keysize 2048 -validity 80000

Key Store Password is: adka_sd8jda

Key Password for <for_corona>: skd8sksad_

Build game (Horse Animation from Samples) with Corona. The app is NOT installed on 4.1.1 with this error:

java.lang.SecurityException: META-INF/TRINACRI.SF has invalid digest for assets/projects/steve\_punk/audio/project/pawn/12.mp3 in /data/app/vmdl-635292339.tmp

I’ve put this file into corona sample project because is one of the file that launch exception: but there are others files like many xml or android library files that i can’t delete or change (holo layout, holo png, …)

Build game manualy with this comad from debug apk:

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore for\_corona.keystore debug.apk for\_corona

Well! In this case I can istall apk on 4.1.1 device!

Java 6 has different signature algorithm from Java 7:

in Java 6 is SHA1withRSA while in Java 7 is SHA256withRSA. So if certifcate is created with Java 6, signing with Java 7  (or with different algorithm) maybe create this problem over same Android version (4.1.1 and 2.3.3 tested).

Thank you

Examples files link: 

https://www.dropbox.com/sh/e5p7qk09e85se30/AACvAUwjvlhL0lM8TpGQ4Yj0a?dl=0

I suspect that the Mac version of the Corona Simulator is failing to find the “jarsigner” on your PATH.  If you install Apple’s version of the JDK, then it *will* be on your PATH and the Corona build system will be able to specify the correct encryption algorithm support by Android as a command line argument.

However, if jarsigner is *not* on your PATH, then Corona’s build system fallsback to signing your APK via “ant”, which does not support selecting the encryption algorithm.  If “ant” on your system is using JDK 7 or newer, then yes, it’ll fail.

So, right, I suspect this is the issue.  To verify, please do the following:

1) Open the “Terminal” app.  (aka: Mac’s command line window.)

2) Type “jarsigner” at the command line and hit enter.

If the Terminal is unable to find the “jarsigner” command line tool, then that’s the issue.  There are 2 ways to solve this:

  1. Update your PATH environment variable to reference your JDK’s “bin” directory containing the “jarsigner” command line tool.  Note that Corona *does* support JDK 7’s jarsigner and will correctly sign with it.

  2. Install Apple’s version of the JDK 6.  This is what most developers do, but note that your system will use that JDK version by default and not Oracle’s.

The jarsigner is just in the path. 

If I run “java -version” the output is

java version "1.6.0\_65" Java(TM) SE Runtime Environment (build 1.6.0\_65-b14-468-11M4828a) Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-468, mixed mode)

While if I type “/usr/libexec/java_home”

/Library/Java/JavaVirtualMachines/jdk1.7.0\_72.jdk/Contents/Home

How to Corona get Java version? 

Dec 17 10:38:12.614 WARNING: display.setStatusBarMode() not supported in the simulator for Custom device Dec 17 10:38:17.266 Using java version "1.7.0\_72" Java(TM) SE Runtime Environment (build 1.7.0\_72-b14) Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode) Dec 17 10:38:17.348 Picked up JAVA\_TOOL\_OPTIONS: -Duser.language=en Dec 17 10:38:17.701 Picked up JAVA\_TOOL\_OPTIONS: -Duser.language=en Dec 17 10:38:18.570 jar signed.

“ant” will use the Java version that your “JAVA_HOME” environment variable references.  Changing that to your JDK 6 root directory will definitely force Corona to use it and resolve the issue.  Although that might have an impact on other Java dev tools that you’re using.  If you do decide to change “JAVA_HOME”, then make sure to *Quit* the Corona Simulator and restart it so that it’s using your updated environment variables.

You shouldn’t theoretically have to change “JAVA_HOME” though.  Having the jarsigner tool in your PATH should be enough.  But I’m more of a Windows guy here at Corona Labs and not as familiar with the OS X side.  (Windows actually makes this a lot easier.  No environment variables required and multiple Java version installations are supported.)

But my JAVA_HOME (environment variables) is linked to Java 6, in fact certificate was created with Java 6 (keytool) from comand line.

While Corona seem to use Java 7 (linked from /usr/libexec/java_home) to sign certificate.

How to solve? Can you help me?

Corona doesn’t should use JAVA_HOME?

You just told me that your JAVA_HOME environment variable is referencing a JDK 7 directory (the “1.7” directory you posted above).  I’m pretty sure that’s the problem.

Other than that, we’re running out of ideas on how to help you.  We know that multiple JDK installations do work on OS X.  I have a MacBook that has both JDK 6 (Apple’s version) and JDK 7 (from Oracle) installed and it builds/signs just fine.  I know it does the same for others too.  I’m sure you’ve found and edge of some kind, but we don’t know what it is.  If it’s not your JAVA_HOME path, then you might have need to consider re-installing the JKD on your system because something about your dev environment is not set up right since it is working for others.

Ok, I’ve resolved my problem.

On Mac OX, there are two way to know Java. With JAVA_HOME variable and with  /usr/libexec/java_home command.

In my environment was linked two different java versione: 6 (JAVA_HOME) and 7 (/usr/libexec/java_home).

My terminal use JAVA_HOME, so when I using keytool my system use Java 6, while Corona uses /usr/libexec/java_home to detected java version (that could be the same as JAVA_HOME) for signing apk.

Since Java 6 and Java 7 uses different signature algorithm, on some Android version (4.1.1 and 2.3.3) an apk could be not installed also the same apk is uploaded with success on Google Play Store.

Glad you figured it out.  And thanks for sharing your findings.  I’m sure it’ll prove useful to others.

Hi, I’ve similar problem

This is my environment

Mac iOS: 10.10.5 Corona: Build: 2015.2785 Java 6 (default) &nbsp;-java version "1.6.0\_65" &nbsp;-Java(TM) SE Runtime Environment (build 1.6.0\_65-b14-468-11M4828a) &nbsp;-Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-468, mixed mode) Java 7 &nbsp;-Using java version "1.7.0\_72" &nbsp;-Java(TM) SE Runtime Environment (build 1.7.0\_72-b14) &nbsp;-Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode)

I’ve created a signed certificate with keytool from comand line, using default java (6).

When build with signed certificates in the Corona Console I see:

Using java version "1.7.0\_72" Java(TM) SE Runtime Environment (build 1.7.0\_72-b14) Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode) Picked up JAVA\_TOOL\_OPTIONS: -Duser.language=en Picked up JAVA\_TOOL\_OPTIONS: -Duser.language=en jar signed.

First ask: why Corona use Java 7???

But the problem is that some device (4.0.1 or 2.3.3) cannot installa apk (from Google Play), the user see this error:

Package file was not signed correctly

Where is the problem? The Java version used by Corona for signed apk? How to change Java for Corona?

Thank you!

The JDK is needed to do Android APK builds and for digital signing.  The same is true for native Android development as well.

Since your Android device is refusing to install your APK due to a signing error, that means their is something wrong with the keystore file that you’ve created.  You need to create a keystore file according to Google’s instructions (link below) at the command line.  You only need to do step 1 in these instructions.  Once the file is created, reference it the Corona Simulator’s build window.

   http://developer.android.com/tools/publishing/app-signing.html#signing-manually

I try but does not works!

The error (during installation) is:

java.lang.SecurityException: META-INF/XXXX.SF has invalid digest for assets/....

The problem seems similar to this post:

https://forums.coronalabs.com/topic/52593-app-does-not-install-on-android-device-certificate-error-invalid-digest-corona-asset-widget-theme/

But I don want disinstalled Java 7

And I think the Corona use Java 7 while building from this message on console?:

Dec 16 11:37:53.185 Using java version "1.7.0\_72" Java(TM) SE Runtime Environment (build 1.7.0\_72-b14) Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode) Dec 16 11:37:55.106 Building android app for user with 2015.2785 Dec 16 11:37:58.729 Using custom build id from app bundle: 00000 (AppSettings.lua) Dec 16 11:37:59.692 BUILD SUCCESSFUL

Thank you!

I try to to sign apk manualy with jarsigner (using Java 6) and I can install apk on device with success!

So, the problem seems that corona use Java 7 when sing apk, and in same device (4.1.1, 2.3.3) the signature doesn’t work.

How can tell to Corona to use JAVA 6, without disinstalled JAVA 7?

I can sign manually but I cannot use zipalign without unaligned apk.

The Windows version of the Corona Simulator supports JDK 6, 7, and 8.  All of these JDK versions will correctly digitally sign the APK.  My Windows OS environment has multiple JDK installed as well and it works.

Are you running the OS X version of the Corona Simulator?

Also, which Corona build # are your running?

(The more info you can provide us, the faster this will go.)