# Android Build Issues

![](https://docs.pixelstrap.net/laravel/taxido/assets/images/icons/errors.png) Common Errors in APK Generation (Android&#x20;Build Issues)<br>
-----------------------

1. **Task :app:bundleReleaseJsAndAssets FAILED**<br>
   * Error Message :<br>

     ```html
     Task :app:bundleReleaseJsAndAssets FAILED
     ```

   * Possible Solutions&#x20;

     * Run the following command before building : <br>

       ```html
        npx react-native start --reset-cache
       ```

     * Try cleaning and rebuilding:

     ```html
      cd android && ./gradlew clean
     ```

     ```html
      cd..
     ```

     ```html
      npx react-native run-android --variant=release
     ```

2. **Keystore file not found for signing config release**<br>

   * Error Message :  <br>

     ```html
     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** :  <br>

     ```html
      signingConfigs {
        release {
            storeFile file('release.keystore')
            storePassword 'your-password'
            keyAlias 'your-key-alias'
            keyPassword 'your-key-password'
        }
      }
     ```

   * If missing, create a new keystore :<br>

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

3. **SDK location not found**<br>
   1. Error Message :<br>

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

      <br>
   2. Possible Solutions :<br>
      * Open android/local.properties and set the correct SDK path :<br>

        ```html
         sdk.dir=/Users/your-username/Library/Android/sdk  (Mac)
        ```

        ```html
         sdk.dir=C:\\Users\\your-username\\AppData\\Local\\Android\\Sdk  (Windows)
        ```

      * If missing, create the file and add the path manually.\ <br>

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

   * Ensure you have built the APK correctly :  <br>

     ```html
      cd android && ./gradlew assembleRelease
     ```

   * The APK will be located at :<br>

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

   <br>

5. **Unable to resolve dependency for ':app\@release/compileClasspath'**\
   \
   Possible Solutions : &#x20;

   * Run :  <br>

     ```html
      cd android && ./gradlew clean
     ```

     ```html
      ./gradlew --refresh-dependencies
     ```

   * Check if any library is missing in package.json and reinstall :<br>

   ```html
    npm install
   ```

6. **React Native Hermes: Release build fails**<br>
   1. Error Message :   <br>

      ```html
      error: no suitable constructor found
      ```

   2. Possible Solutions :<br>

      * If using Hermes, ensure it's enabled : <br>

        ```html
        enableHermes: true
        ```

      * Try :<br>

      ```html
      cd android && ./gradlew clean
      ```

      <br>

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

   1. Error Message :   <br>

      ```html
      Execution failed for task ':app:mergeDexRelease'.
      ```

   2. Possible Solutions :

   ```html
    defaultConfig {
       multiDexEnabled true
       }
   ```

8. **Install Multidex :** <br>

   ```html
   npm install @react-native-community/multidex
   ```

9. **Rebuild the app :**  <br>

   ```html
   cd android && ./gradlew clean
   ```

   ```html
   npx react-native run-android --variant=release
   ```

   <br>

10. **Could not determine the dependencies of task ':app:compileReleaseJavaWithJavac'**\
    \
    Possible Solutions :
    * Ensure JDK 17 is installed :    <br>

      ```html
      java -version
      ```

    * If not Java 17, update it :  <br>

      ```html
      export JAVA_HOME=$(/usr/libexec/java_home -v 17)
      ```

    * Rebuild the app.<br>

11. **minCompileSdk (31) is greater than compileSdkVersion (30)**  \
    \
    Error Message :    <br>

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

    \
    Possible Solutions :\
    &#x20;&#x20;

    * Update your android/build.gradle : <br>

      ```html
      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.**<br>

    12. Error Message :    <br>

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

        <br>

        Possible Solutions :\
        &#x20;&#x20;

        * Delete the `.cxx` folder<br>

          ```html
          rm -rf android/app/.cxx
          ```

        * **Modify the file in node\_modules** Navigate to:<br>

          ```html
          node_modules/react-native-svg/common/cpp/react/renderer/components/rnsvg/RNSVGLayoutableShadowNode.cpp
          ```

        * Open the file and **replace all occurrences of** `StyleSizeLength` with `StyleLength`.<br>

          ```html
          StyleSizeLengthReplace with StyleLength
          ```
    13.

    ```
    Error Message :    <br>
    ```

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

    <br>

    Possible Solutions :\
    &#x20;&#x20;

    *   Delete the `.cxx` folder<br>

        ```html
        rm -rf android/app/.cxx
        ```



    *   **Modify the file in node\_modules** Navigate to:<br>

        ```html
        node_modules/react-native-svg/common/cpp/react/renderer/components/rnsvg/RNSVGLayoutableShadowNode.cpp
        ```


    *   Open the file and **replace all occurrences of** `StyleSizeLength` with `StyleLength`.<br>

        ```html
        StyleSizeLengthReplace with StyleLength
        ```
    ````

    Rebuild the project :

    ```
    cd android && ./gradlew clean
    npx react-native run-android or ./grdalew assebelDebug
    ```

13. Build failed due to **Firebase package version mismatch**.\
    &#x20;\
    Possible Solution:<br>

    Please make sure **all Firebase packages are using the same version** to avoid compatibility issues.<br>

    Use the following versions:

    ```json
    "@react-native-firebase/app": "21.11.0",
    "@react-native-firebase/auth": "21.11.0",
    "@react-native-firebase/messaging": "21.11.0",
    "@react-native-firebase/storage": "21.11.0"
    ```

    #### Error Message

    Build failed due to **Firebase package version mismatch**.\
    Firebase native modules require all `@react-native-firebase/*` packages to be on the **same version**.\
    If versions are different, Android/iOS build may fail.

## <img src="https://docs.pixelstrap.net/laravel/taxido/assets/images/icons/icon.png" alt="" data-size="line"> **General Fix for APK Issues**

<pre class="language-html"><code class="lang-html">cd android

<strong>./gradlew clean
</strong>
For Debug APK: ./gradlew assembleDebug 

For Release APK: ./gradlew assembleRelease

</code></pre>

{% hint style="warning" %}
Note: Make sure that you do not use the ^ (caret) symbol while installing this package. Using ^ allows npm to automatically install a newer version, which can again lead to version mismatch problems.
{% endhint %}

## <br>
