Troubleshooting Common Issues

Build Failure - SDK Path Error:

  • Problem: When running npx react-native run-android, the build failed with an exception stating that the SDK location was not found. Specifically, it mentioned a "Trailing char < > at index 40" error, indicating an issue with the SDK path.

  • Resolution:

    • Verified the local.properties file in the D:\MyProject\android directory.

    • Ensured that the sdk.dir path was correctly set to C:\\Users\\shubh\\AppData\\Local\\Android\\Sdk with no trailing spaces or hidden characters.

    • The local.properties file was recreated using a command to avoid any formatting issues.

sdk.dir = C:\\Users\\shubh\\AppData\\Local\\Android\\Sdk

Environment Variable Issues - ANDROID_HOME:

  • Problem: The ANDROID_HOME environment variable was not set correctly, leading to issues in locating the Android SDK.

  • Resolution:

    • The ANDROID_HOME environment variable was manually set to the correct SDK path.

    • The variable was verified and set permanently in the system's environment variables.

Final Build Failure - Java Dependency Issue:

  • Problem: The build failed again with an error related to Java dependencies, specifically involving a "Trailing char < > at index 40."

  • Resolution:

    • Ensured that the local.properties file had no hidden or extra characters.

    • Rechecked and corrected the local.properties file, ensuring the SDK path was correctly formatted.

    • Rebuilt the project using the gradlew clean command to ensure a clean environment.

💡
Final Outcome:
  • The issues were resolved by carefully verifying and correcting the SDK path in the local.properties file, setting the ANDROID_HOME environment variable, and ensuring no extraneous characters were causing the build to fail.
0
Subscribe to my newsletter

Read articles from Shubham Deshmukh directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Shubham Deshmukh
Shubham Deshmukh

My career objective is to be a competent individual who can contribute significantly to an organization's growth and also get valuable exposure, that would help me enhance my skill sets and provide me with opportunities to grow and further develop my talents as an individual. Also will offer me a work-life balance.