react native trouble shooting

  1. Could not find com.android.tools.build:gradle:8.1.1.
  2. Could not determine the dependencies of task ‘:app:compileDebugKotlin’.
  3. No online devices found.
  4. Unable to load script.
  5. generate index.android.bundle
  6. Crash on Android 5.1

Could not find com.android.tools.build:gradle:8.1.1.

  1. Check dependencies in build.gradle, ensure that the following dependency exists:
1
2
3
dependencies {
classpath 'com.android.tools.build:gradle:8.1.1'
}
  1. Open https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/8.1.1/gradle-8.1.1.pom in your browser and ensure it is accessible.

  2. Sync project with gradle files

Could not determine the dependencies of task ‘:app:compileDebugKotlin’.

  1. Check your network connection and/or proxy settings.

No online devices found.

Unable to load script.

Make sure you’re either running Metro (run ‘npx react-native start’) or that your bundle ‘index.android.bundle’ is packaged correctly for release.

generate index.android.bundle

To generate the index.android.bundle file for your React Native app in Android Studio, follow these steps:

  1. Open a Terminal or Command Prompt:
  • Navigate to your project’s root directory using the terminal or command prompt.
  1. Run the Following Command:
  • Execute the following command to generate the index.android.bundle file:
    react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
  • This command will create the bundle file and place it in the specified location.
  1. Build Your App:
    • After generating the bundle, you can proceed with building your app using Android Studio or by running the following command:
      cd android && ./gradlew assembleRelease
    • This will create the APK file for your React Native app.

Crash on Android 5.1

  1. Use the React Native 0.71.x version, newer versions have dropped support for Android 5.1
  2. Run the following command to create a TV project for Android 5.1+:
1
npx [email protected] init TestApp [email protected]

This command will create a new project named TestApp in the TestApp directory using the react-native-tvos template.