- Could not find com.android.tools.build:gradle:8.1.1.
- Could not determine the dependencies of task ‘:app:compileDebugKotlin’.
- No online devices found.
- Unable to load script.
- generate index.android.bundle
- Crash on Android 5.1
- ERROR: JAVA_HOME is not set and no ‘java’ command could be found in your PATH.
- Exception in thread “main” java.io.IOException: Downloading from https://services.gradle.org/distributions/gradle-7.5.1-all.zip failed: timeout
- Could not open settings generic class cache for settings file
- SDK location not found. Define a valid SDK location with an ANDROID_HOME environment variable or by setting the sdk.dir path in your project’s local properties fil
Could not find com.android.tools.build:gradle:8.1.1.
- Check dependencies in
build.gradle
, ensure that the following dependency exists:
1 | dependencies { |
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.
Sync project with gradle files
Could not determine the dependencies of task ‘:app:compileDebugKotlin’.
- 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:
- Open a Terminal or Command Prompt:
- Navigate to your project’s root directory using the terminal or command prompt.
- 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.
- 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.
- After generating the bundle, you can proceed with building your app using Android Studio or by running the following command:
Crash on Android 5.1
- Use the React Native 0.71.x version, newer versions have dropped support for Android 5.1
- 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.
ERROR: JAVA_HOME is not set and no ‘java’ command could be found in your PATH.
First, download and install the JDK (Java Development Kit) if it’s not already installed:
- Go to the Java JDK download page or install OpenJDK.
- Install the JDK following the instructions for your operating system
Set the JAVA_HOME Environment Variable
Once the JDK is installed, you’ll need to set JAVA_HOME
and add it to your system PATH
.
On Windows:
Open System Properties > Advanced > Environment Variables.
Under System Variables, click New and enter:
- Variable name:
JAVA_HOME
- Variable value: The path to your JDK installation, usually something like
C:\Program Files\Java\jdk-17
.
Find the Path variable under System Variables, click Edit, and add a new entry:
Add %JAVA_HOME%\bin
to the path list.
Restart any open command prompts or terminals.
Exception in thread “main” java.io.IOException: Downloading from https://services.gradle.org/distributions/gradle-7.5.1-all.zip failed: timeout
My solution was to update my global ~/.gradle/gradle.properties
file with the correct proxy settings:
1 | org.gradle.daemon=true |
Could not open settings generic class cache for settings file
So the problem arises from inconsistency in the Java version installed on your machine, the default Java version configured on your android studio and the gradle version for your project.
https://docs.gradle.org/current/userguide/compatibility.html