How to build and sign Android APK using JDK 7 with Netbeans

June 7th, 2012 | by Tonny Kohar |

If you build and sign android application using jdk 7, the result apk could not be installed on physical device,
see http://code.google.com/p/android/issues/detail?id=19567

It is because the default digest algorithm for Java 7 is SHA-256,
see http://docs.oracle.com/javase/7/docs/technotes/tools/windows/jarsigner.html

So one of the easiest way to sign android apk using jdk 7 is by adding the following to the build.xml

<presetdef name="signjar">
    <signjar sigalg="MD5withRSA" digestalg="SHA1" />
</presetdef>

note: the above example is using Netbeans 7.1.2 with NbAndroid plugins.
Other IDE should adjust accordingly.

Tags: , ,

  1. 6 Responses to “How to build and sign Android APK using JDK 7 with Netbeans”

  2. By Xavi Ivars on Aug 17, 2012 | Reply

    Thank you very much!

    I had the problem, but didn’t know how to solve it, and thanks to your post I’ve fixed it! 😉

  3. By apk android on Jan 3, 2014 | Reply

    Thanks a lot of

  4. By apk android on Jan 3, 2014 | Reply

    Thanks very much

  1. 3 Trackback(s)

  2. Aug 16, 2012: Android netbeans | Ballocapesso
  3. May 15, 2020: keytool – Published Android apk gives error "Package file was not signed correctly"-ThrowExceptions – ThrowExceptions
  4. May 26, 2022: Published Android apk gives error "Package file was not signed correctly"

You must be logged in to post a comment.