Search code examples
react-nativegradleandroid-app-bundle

trying to generate an AAB for a react native app


i have an app that is published in play store, since play store is asking to change the targetSdkVersion to 34, i went to android/build.gradle and manually changed the targetSdkVersion // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        minSdkVersion = 23
        compileSdkVersion = 34
        targetSdkVersion = 34
        kotlin_version = "1.8.10" 
        googlePlayServicesVersion = "21.0.1"
        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10")
    }
    allprojects{
        repositories {
            google()
            mavenCentral()
            }
    }
}

no im trying to generate the AAB file and this error is persisting after trying to upgrade the gradle the kotlin plugin and the kotlin version, ive tryed also to clean and reebuild the app. my package.json

{
  "name": "wyngo",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest"
  },
  "dependencies": {
    "@gorhom/bottom-sheet": "^4.6.0",
    "@react-native-async-storage/async-storage": "^1.21.0",
    "@react-native-community/checkbox": "^0.5.16",
    "@react-native-community/cli-platform-android": "^13.2.0",
    "@react-native-community/datetimepicker": "^7.6.2",
    "@react-native-community/geolocation": "^3.3.0",
    "@react-native-community/slider": "^4.5.2",
    "@react-native-masked-view/masked-view": "^0.3.1",
    "@react-native-picker/picker": "^2.7.7",
    "@react-native-vector-icons/fontawesome6": "^6.6.0-alpha.28",
    "@react-navigation/bottom-tabs": "^6.5.11",
    "@react-navigation/drawer": "^6.6.6",
    "@react-navigation/elements": "^1.3.21",
    "@react-navigation/native": "^6.1.9",
    "@react-navigation/native-stack": "^6.9.17",
    "@react-navigation/stack": "^6.3.20",
    "@shopify/flash-list": "^1.6.3",
    "axios": "^1.6.3",
    "formik": "^2.4.5",
    "geolib": "^3.3.4",
    "i18next": "^23.7.20",
    "react": "18.2.0",
    "react-i18next": "^14.0.1",
    "react-native": "0.72.7",
    "react-native-android-open-settings": "^1.3.0",
    "react-native-asset": "^2.1.1",
    "react-native-date-picker": "^5.0.4",
    "react-native-draggable-flatlist": "^4.0.1",
    "react-native-draggable-grid": "^2.2.1",
    "react-native-event-listeners": "^1.0.7",
    "react-native-geolocation-service": "^5.3.1",
    "react-native-gesture-handler": "^2.18.1",
    "react-native-image-picker": "^7.1.2",
    "react-native-image-viewing": "^0.2.2",
    "react-native-indicators": "^0.17.0",
    "react-native-linear-gradient": "^2.8.3",
    "react-native-maps": "^1.14.0",
    "react-native-multi-slider": "^0.3.6",
    "react-native-paper": "^5.12.1",
    "react-native-picker-select": "^9.1.3",
    "react-native-radio-buttons-group": "^3.0.7",
    "react-native-ratings": "^8.1.0",
    "react-native-reanimated": "^3.6.2",
    "react-native-responsive-screen": "^1.4.2",
    "react-native-safe-area-context": "^4.8.2",
    "react-native-screens": "^3.29.0",
    "react-native-toast-message": "^2.2.0",
    "react-native-vector-icons": "^10.0.3",
    "react-native-webview": "^13.7.0",
    "yup": "^1.3.3"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native/eslint-config": "^0.72.2",
    "@react-native/metro-config": "^0.72.11",
    "@tsconfig/react-native": "^3.0.0",
    "@types/react": "^18.0.24",
    "@types/react-native-vector-icons": "^6.4.18",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.2.1",
    "eslint": "^8.19.0",
    "jest": "^29.2.1",
    "metro-react-native-babel-preset": "0.76.8",
    "prettier": "^2.4.1",
    "react-test-renderer": "18.2.0",
    "typescript": "4.8.4"
  },
  "engines": {
    "node": ">=16"
  }
}

and the error: error Failed to build the app.

Error: Command failed with exit code 1: gradlew.bat app:bundleRelease
    at makeError (C:\Users\BILEL\Downloads\wyngo_Frontend-main\wyngo_Frontend-main\node_modules\execa\lib\error.js:60:11)
    at module.exports.sync (C:\Users\BILEL\Downloads\wyngo_Frontend-main\wyngo_Frontend-main\node_modules\execa\index.js:194:17)
    at build (C:\Users\BILEL\Downloads\wyngo_Frontend-main\wyngo_Frontend-main\node_modules\react-native\node_modules\@react-native-community\cli-platform-android\build\commands\buildAndroid\index.js:95:22)
    at Object.buildAndroid [as func] (C:\Users\BILEL\Downloads\wyngo_Frontend-main\wyngo_Frontend-main\node_modules\react-native\node_modules\@react-native-community\cli-platform-android\build\commands\buildAndroid\index.js:87:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Command.handleAction (C:\Users\BILEL\Downloads\wyngo_Frontend-main\wyngo_Frontend-main\node_modules\@react-native-community\cli\build\index.js:111:9)
info Run CLI with --verbose flag for more details.

Solution

  • I was also seeing this same error message, but the real error was further up.

    It looked like this:

        > 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
           > Failed to read key my-key-alias from store "....\android\app\release.keystore": Get Key failed: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
    

    This is basically "bad" configuration of the keystore, somewhere.

    If you create an upload key according to the docs, Publish to Google Play Store - React Native, it is (for me, anyway) unclear what the values of MYAPP_UPLOAD_STORE_PASSWORD and MYAPP_UPLOAD_KEY_PASSWORD are.

    If following the docs, these are both the same and are the value the you put when prompted after running the keytool command (keytool -genkeypair -v -storetype PKCS12 -keystore my-upload-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000).

    I also found that the my Gradle variables HAD to be in android/gradle.properties. They were not discovered from my User's directory (and therefore get checked in to Git).