robotAndroid Build Issues

Common Errors in APK Generation (Android Build Issues)

  1. Task :app:bundleReleaseJsAndAssets FAILED

    • Error Message :

      Task :app:bundleReleaseJsAndAssets FAILED
    • Possible Solutions

      • Run the following command before building :

         npx react-native start --reset-cache
      • Try cleaning and rebuilding:

       cd android && ./gradlew clean
       cd..
       npx react-native run-android --variant=release
  2. Keystore file not found for signing config release

    • Error Message :

      Keystore file '/android/app/release.keystore' not found for signing config 'release'
    • Possible Solutions :

    • Ensure your keystore file is placed in android/app/.

    • Check your android/app/build.gradle for :

       signingConfigs {
         release {
             storeFile file('release.keystore')
             storePassword 'your-password'
             keyAlias 'your-key-alias'
             keyPassword 'your-key-password'
         }
       }
    • If missing, create a new keystore :

     keytool -genkey -v -keystore release.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
  3. SDK location not found

    1. Error Message :

       SDK location not found. Define location with sdk.dir in the local.properties file.

    2. Possible Solutions :

      • Open android/local.properties and set the correct SDK path :

         sdk.dir=/Users/your-username/Library/Android/sdk  (Mac)
         sdk.dir=C:\\Users\\your-username\\AppData\\Local\\Android\\Sdk  (Windows)
      • If missing, create the file and add the path manually.\

  4. app-release.apk not found after build Possible Solutions :

    • Ensure you have built the APK correctly :

       cd android && ./gradlew assembleRelease
    • The APK will be located at :

     android/app/build/outputs/apk/release/app-release.apk

  5. Unable to resolve dependency for ':app@release/compileClasspath' Possible Solutions :

    • Run :

       cd android && ./gradlew clean
       ./gradlew --refresh-dependencies
    • Check if any library is missing in package.json and reinstall :

     npm install
  6. React Native Hermes: Release build fails

    1. Error Message :

      error: no suitable constructor found
    2. Possible Solutions :

      • If using Hermes, ensure it's enabled :

        enableHermes: true
      • Try :

      cd android && ./gradlew clean

  7. Execution failed for task ':app:mergeDexRelease'

    1. Error Message :

      Execution failed for task ':app:mergeDexRelease'.
    2. Possible Solutions :

     defaultConfig {
        multiDexEnabled true
        }
  8. Install Multidex :

    npm install @react-native-community/multidex
  9. Rebuild the app :

    cd android && ./gradlew clean
    npx react-native run-android --variant=release

  10. Could not determine the dependencies of task ':app:compileReleaseJavaWithJavac' Possible Solutions :

    • Ensure JDK 17 is installed :

      java -version
    • If not Java 17, update it :

      export JAVA_HOME=$(/usr/libexec/java_home -v 17)
    • Rebuild the app.

  11. minCompileSdk (31) is greater than compileSdkVersion (30) Error Message :

    Android dependency 'androidx.core:core' has different version for the compile

    Possible Solutions :

    • Update your android/build.gradle :

      compileSdkVersion = 33
      targetSdkVersion = 33
    • Rebuild the project :

      cd android && ./gradlew clean
      npx react-native run-android --variant=releas
  12. Execution failed for task StyleSizeLength is not supported.

    Error Message :

    Invariant Violation: StyleSizeLength is not supported. You need to replace StyleSizeLength with StyleLength.

    Possible Solutions :

    • Delete the .cxx folder

      rm -rf android/app/.cxx
    • Modify the file in node_modules Navigate to:

      node_modules/react-native-svg/common/cpp/react/renderer/components/rnsvg/RNSVGLayoutableShadowNode.cpp
    • Open the file and replace all occurrences of StyleSizeLength with StyleLength.

      StyleSizeLengthReplace with StyleLength

Rebuild the project :

General Fix for APK Issues

circle-exclamation

Last updated