9

I'm currently building my android APK with react native, following the doc.

I got this error:

./gradlew bundleRelease
WARNING:: Please remove usages of `jcenter()` Maven repository from your build scripts and migrate your build to other Maven repositories.
This repository is deprecated and it will be shut down in the future.
See http://developer.android.com/r/tools/jcenter-end-of-service for more information.
Currently detected usages in: project ':react-native-async-storage_async-storage', project ':react-native-camera', project ':react-native-pager-view', ...
> Task :app:signReleaseBundle FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:signReleaseBundle'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.FinalizeBundleTask$BundleToolRunnable
   > Java heap space

* 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 15s
213 actionable tasks: 15 executed, 198 up-to-date

When I run ./gradlew signingReport everything is OK:

WARNING:: Please remove usages of `jcenter()` Maven repository from your build scripts and migrate your build to other Maven repositories.
This repository is deprecated and it will be shut down in the future.
See http://developer.android.com/r/tools/jcenter-end-of-service for more information.
Currently detected usages in: project ':react-native-async-storage_async-storage', project ':react-native-camera', project ':react-native-pager-view', ...

> Task :app:signingReport
Variant: debug
Config: debug
Store: /home/alexandre/Documents/project/iWaiterApp/android/app/debug.keystore
Alias: AndroidDebugKey
MD5: 20:F4:61:48:B7:2D:8E:5E:5C:A2:3D:37:A4:F4:14:90
SHA1: 5E:8F:16:06:2E:A3:CD:2C:4A:0D:54:78:76:BA:A6:F3:8C:AB:F6:25
SHA-256: FA:C6:17:45:DC:09:03:78:6F:B9:ED:E6:2A:96:2B:39:9F:73:48:F0:BB:6F:89:9B:83:32:66:75:91:03:3B:9C
Valid until: Tuesday, April 30, 2052
----------
Variant: release
Config: release
Store: /home/alexandre/Documents/project/iWaiterApp/android/app/my-upload-key.keystore
Alias: my-key-alias
MD5: 86:65:36:56:D2:FE:31:9A:5D:B1:2B:67:B2:0E:57:C4
SHA1: 25:90:1A:0B:0C:4E:95:CE:CE:E2:40:5F:B9:0E:D6:46:0D:41:F9:45
SHA-256: BC:82:0F:E2:FC:24:52:DB:14:95:CD:D7:06:9B:D6:CB:50:F1:44:85:FC:EC:4C:65:CD:CB:10:8B:E8:00:04:9C
Valid until: Wednesday, February 3, 2049
----------
// ...
----------
Variant: releaseUnitTest
Config: debug
Store: /home/alexandre/.android/debug.keystore
Alias: AndroidDebugKey
MD5: 20:F4:61:48:B7:2D:8E:5E:5C:A2:3D:37:A4:F4:14:90
SHA1: 5E:8F:16:06:2E:A3:CD:2C:4A:0D:54:78:76:BA:A6:F3:8C:AB:F6:25
SHA-256: FA:C6:17:45:DC:09:03:78:6F:B9:ED:E6:2A:96:2B:39:9F:73:48:F0:BB:6F:89:9B:83:32:66:75:91:03:3B:9C
Valid until: Tuesday, April 30, 2052
----------

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 5s
11 actionable tasks: 11 executed

Here is my android/app/build.gradle

// ...
android {
    // ...
    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
                storeFile file(MYAPP_UPLOAD_STORE_FILE)
                storePassword MYAPP_UPLOAD_STORE_PASSWORD
                keyAlias MYAPP_UPLOAD_KEY_ALIAS
                keyPassword MYAPP_UPLOAD_KEY_PASSWORD
            }
        }
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'AndroidDebugKey'
            keyPassword 'android'
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://reactnative.dev/docs/signed-apk-android.
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }

    // ...
}

dependencies {
    // ...
}

// ...

Here is my android/gradle.properties

android.useAndroidX=true

android.enableJetifier=true

FLIPPER_VERSION=0.93.0

MYAPP_UPLOAD_STORE_FILE=my-upload-key.keystore
MYAPP_UPLOAD_KEY_ALIAS=my-key-alias
MYAPP_UPLOAD_STORE_PASSWORD=computer
MYAPP_UPLOAD_KEY_PASSWORD=computer

I could find a way to solve this issue on this post:

I also use the official template for my debug.keystore: https://raw.githubusercontent.com/facebook/react-native/master/template/android/app/debug.keystore

How to solve this issue ?

Lenny4
  • 1,215
  • 1
  • 14
  • 33

1 Answers1

26

Even though you are getting an error at the signing step it seems that is not related to it, but instead just java running out of memory.

Try adding the line below into your gradle.properties to increase the Java heap size.

org.gradle.jvmargs=-Xmx2g -XX\:MaxHeapSize\=4g
isidoro98
  • 276
  • 3
  • 4
  • # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. # Default value: -Xmx512m -XX:MaxMetaspaceSize=256m org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m – questerstudios Apr 10 '23 at 16:08