question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android] Gradle APK Sign issues since upgrade to 0.59

See original GitHub issue

🐛 Bug Report

The android signing process seems to be broken since react-native version 0.59.0. I’ve upgraded from 0.57.8.

After upgrading the project, this did not work anymore. The passwords are getting passed correctly to the gradle taskGraph part. They seem to be overridden or assigned too late in the build process.

My guess is there was some change in gradle, which changed the build order. Thanks for your help.

To Reproduce

  • Initialize react native project
  • Configure your project for app signing
  • Build using the following:./gradlew assembleRelease -PkeyPass=mySecretKey -PkeystorePass=mySecretKeystorePass

Expected Behavior

Signing should work.

Stack Trace

> Task :app:packageRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:packageRelease'.
> com.android.ide.common.signing.KeytoolException: Failed to read key com.foo.app from store "/Users/foo/app/store.keystore.": Keystore was tampered with, or password was incorrect

Code Example

// android/app/build.gradle

gradle.taskGraph.whenReady { taskGraph ->
    if (taskGraph.hasTask(':app:assembleRelease')) {
        android.signingConfigs.release.storePassword = keystorePass
        android.signingConfigs.release.keyPassword = keyPass
    }
}
...
android {
    ...
    signingConfigs {
        release {
            storeFile file(MY_STORE_FILE)
            keyAlias MY_STORE_ALIAS
            storePassword ''
            keyPassword ''
        }
    }
    ...
    buildTypes {
        release {
            ...
            signingConfig signingConfigs.release
            ...
        }
    }
    ...

Environment

  React Native Environment Info:
    System:
      OS: macOS 10.14.2
      CPU: x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
      Memory: 12.72 GB / 32.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 8.12.0 - /usr/local/bin/node
      Yarn: 1.15.2 - /usr/local/bin/yarn
      npm: 6.7.0 - /usr/local/bin/npm
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        Build Tools: 23.0.1, 26.0.2, 26.0.3, 27.0.0, 27.0.2, 27.0.3, 28.0.2, 28.0.3
        API Levels: 14, 21, 23, 25, 26, 27, 28
    IDEs:
      Android Studio: 3.3 AI-182.5107.16.33.5264788
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: ^0.59.1 => 0.59.1 
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-create-library: 3.1.2
      react-native-git-upgrade: 0.2.7

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
abdurahmanadiloviccommented, Apr 30, 2019

I had the same issue, the problem was due to the gradle cache, I tried to build my app while hard-coding a wrong password in the app gradle file and that password got cached in the gradle build process. So I just cleaned the project from android studio and the new gradle config took affect, which generated a signed apk successfully.

I just ran grep to find out where was the old keystore path saved, as it turned out: in some build folder

grep -r "keystores/release_keystore_3.jks" .

Returned this

./app/build/intermediates/signing_config/release/out/signing-config.json:{"mName":"release","mStoreFile":"/somepath/keystores/release_keystore_3.jks","mStorePassword":"","mKeyAlias":"test","mKeyPassword":"test","mStoreType":"pkcs12","mV1SigningEnabled":true,"mV2SigningEnabled":true}

So try to clean the project from android studio and then run ./gradlew assembleRelease

2reactions
onisaintcommented, Jul 8, 2019

./gradlew clean in android folder and rebuild

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to build signed apk after upgrading to react native 0.59.3
have upgraded recently to react native v0.59.3 and am using react-native-google-places and react-native maps packages latest versions.
Read more >
Known issues with Android Studio and Android Gradle Plugin
This update causes an underlying behavior change related to signing keys. When you navigate to Build > Generate Signed Bundle / APK and...
Read more >
React Native Generate APK — Debug and Release APK
An Android Package Kit (APK) is the package file format used by the Android OS for distribution and installation of mobile apps.
Read more >
Upgrade to React Native 0.59 - Matt Oakes
Firstly, check the React Native issue tracker to see if there are any major issues ... React Native 0.59 has various changes to...
Read more >
Characterizing Android App Signing Issues
MF, it is possible that (1) the. APK has been modified by the attackers, as the attackers could remove files from the zip...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found