4

The problem is arising in Android Studio 3.0.

When I create a new project, everything works fine but after sometime, the error

Error:org.gradle.tooling.BuildException: Failed to generate v1 signature

Starts to appear automatically which causes the gradle to fail.

When I run it with --stacktrace, here's what it shows me:

Information:Gradle tasks [:app:assembleDebug]

Error:org.gradle.tooling.BuildException: Failed to generate v1 signature

Error:java.io.IOException: Failed to generate v1 signature

Error:java.security.InvalidKeyException: Failed to sign using signer "CERT"

Error:java.security.InvalidKeyException: Failed to sign using SHA1withDSA

Error:java.security.InvalidKeyException: The security strength of SHA-1 digest algorithm is not sufficient for this key size

Information:BUILD FAILED in 1s

5 errors 0 warnings

Here is the full Gist of the Gradle console Gist

I am using Windows 10 X64 with JDK 8 X64.

Any help to solve this problem will be greatly appreciated!

Community
  • 1
  • 1
HQuser
  • 640
  • 10
  • 26
  • 1
    I'm also seeing this - some research suggests that the Java 8 "keytool" program has changed some default settings and that it produces keys that don't work for signing with older Java versions unless some options are changed. The suggestion is to change SHA1 to SHA256, but I don't know how to do that. – Jules Jan 15 '18 at 12:33
  • but even the Android Studio's embedded JDK is not working, the point is, shouldn't Android Studio team have tested at least their embedded JDK before releasing it to public?... – HQuser Jan 15 '18 at 15:27
  • I am using android studio 3.0 it is working fine. – Nirmal Dhara Jan 15 '18 at 16:49

2 Answers2

14

I found I was able to fix this issue by using the following command line to build a new key file, as desribed at https://developer.android.com/studio/publish/app-signing.html:

keytool -genkey -v -keystore my-release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias my-alias

Specifically, I believe the problem is that the default has changed from RSA to DSA at some point, and the tools don't work correctly with large DSA keys.

Jules
  • 14,841
  • 9
  • 83
  • 130
  • With new key file, upload to play store and it shows "Your Android App Bundle is signed with the wrong key. Ensure that your App Bundle is signed with the correct signing key and try again. Your app bundle is expected to be signed with the certificate with fingerprint:" – JasonHsieh Nov 10 '21 at 09:01
1

Try add the following to build.gradle and build it again.

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}
Christos Lytras
  • 36,310
  • 4
  • 80
  • 113
Pankaj Kant Patel
  • 2,050
  • 21
  • 27
  • I tried that you suggested but unfortunately, the same problem persists. – HQuser Jan 14 '18 at 10:39
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/163137/discussion-between-hquser-and-pankaj-kant-patel). – HQuser Jan 14 '18 at 10:56