Unable to run React-Native - javascript

After running npx react-native run-android here is the message from terminal:
FAILURE: Build failed with an exception.
Where:
Build file '/Users/vivek/Documents/Code-Here/React-Native/instaClone/android/app/build.gradle' line: 1
What went wrong:
A problem occurred evaluating project ':app'.
Failed to apply plugin 'com.android.internal.application'.
Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing org.gradle.java.home in gradle.properties.
Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 7s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
Where:
Build file '/Users/vivek/Documents/Code-Here/React-Native/instaClone/android/app/build.gradle' line: 1
What went wrong:
A problem occurred evaluating project ':app'.
Failed to apply plugin 'com.android.internal.application'.
Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing org.gradle.java.home in gradle.properties.

Be sure to always read the error message carefully, because it will likely tell you what is wrong and how you can fix it!
In this case, the error is telling you that you don't have the correct version of Java installed on your system. Gradle, which React Native uses to create a native Android build, requires Java 11 to be installed on your system, whereas you only have version 1.8.
This means you need to install an up-to-date JDK, which you can do by following the React Native Environment Setup instructions for Android for your specific operation system.

Related

new to Apache Cordova: build failed

I am trying to build an Adroid app with javascript... using Apache Cordova. I have followed the instructions and installed the required components but it doesn't work! I get this when I enter build:
C:\Users\qiova\cordova\hello>cordova build
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=undefined (DEPRECATED)
Using Android SDK: C:\Users\qiova\AppData\Local\Android\sdk
Subproject Path: CordovaLib
Subproject Path: app
FAILURE: Build failed with an exception.
Where:
Script 'C:\Users\qiova\cordova\hello\platforms\android\CordovaLib\cordova.gradle' line: 69
What went wrong:
A problem occurred evaluating script.
No installed build tools found. Please install the Android build tools version 30.0.3.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.1.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 3s
Command failed with exit code 1: C:\Users\qiova\cordova\hello\platforms\android\gradlew cdvBuildDebug -b C:\Users\qiova\cordova\hello\platforms\android\build.gradle
I am trying to build an Adroid app with javascript... using Apache Cordova. I have followed the instructions and installed the required components but it doesn't work!
You can download an android sdk in android studio. Just go to settings preferences and search for sdk, there you can add build tools for version 30.0.3. There you can also see what the path is for the sdk. You should add that path to your environment variables (~/.zshrc)
ANDROID_SDK_ROOT=PATH/TO/SDK
and add the thools to your path:
PATH=ANDROID_SDK_ROOT/tools:$PATH
You should also add the folder that contains you platform tools to your path. You can download those here: https://developer.android.com/studio/releases/platform-tools
If you are still getting the error, you can explicitly point to your build tools as well, by adding them to you environment variables too, with: PATH=${PATH}:path/to/build/tools (they are inside your sdk, platform tools should be there too)
Let me know if you still experience errors.

I have downloaded the latest version of Gradle 7.3 that I would like to use in my Visual studio project EXPO

I double checked to see if I have it installed..
Gradle 7.3
so that's fine.. the problem comes when I enter the command gradle --daemon
I get this error
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'RentInCars'.
> Could not resolve all files for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:7.2.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/7.2/gradle-7.2.pom
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/7.2/gradle-7.2.pom
- https://jcenter.bintray.com/com/android/tools/build/gradle/7.2/gradle-7.2.pom
Required by:
project :
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.3/userguide/command_line_interface.html#sec:command_line_warnings
I tried using sudo gradle --daemon.. still gives me the same error..
what should I try next?
As we discussed in comments , you ll need VPN but not any VPN .
You have to know what port your vpn is working on .
for example , if you downloaded psiphone , you can go to settings , then local proxy ports and you can add 12345 as port for example .
then you need to go to .gradle folder , if your using windows its usually located at USER/%USERNAME%/.gradle , and create a global gradle.properties and then add the following .
systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=12345
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=12345
This will redirect all gradle connection throw your proxy , in the case psiphone for example.
I have also tried this and have faced the same issue.
I later find Gradle 7.3 is not added here yet

Error message when launching android emulator

I tried launch my app in React Native with npx react-native run-android on terminal and this error happen
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warning
Picked up _JAVA_OPTIONS: -Xmx512M
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Build file 'C:\Users\mikae\Desktop\AppDentista\android\app\build.gradle' line: 87
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not read script 'C:\Users\mikae\Desktop\AppDentista\node_modules\expo-updates\scripts\create-manifest-android.gradle' as it does not exist.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> compileSdkVersion is not specified.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 45s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Picked up _JAVA_OPTIONS: -Xmx512M
I wanna start and install my application on Android emulator, but this error always happen when I try. This says something is missing, but I don't know what. I didn't find the same problem as mine elsewhere on the internet
I already got, if you have the same problem. Do you need install all dependencies again (Android Studio, React and Java). After that, create a project with npx react-native init Project, and finish!

How to fix Deprecated Gradle when building apk releases is react native?

When there is no error in the developer process but when I want to Build APK release on react native an error occurs ?.
I have tried clean gradle but it still has errors and gradle native still depracated
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 2m 1s
51 actionable tasks: 51 executed ```
I expectd for a solution so that the Build Release APK can react natively.

I'm using react-native-photo-upload library to upload profile pic but it's throwing build failed error

The libary I'm using is yarn add react-native-photo-upload from https://www.npmjs.com/package/react-native-photo-upload
and it's throwing the following error:
**/home/haseeb/Desktop/RN/myProject/node_modules/react-native-image-picker/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:15:21-54: AAPT: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
/home/haseeb/Desktop/RN/myProject/node_modules/react-native-image-picker/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:15: error: Error: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
:react-native-image-picker:processReleaseResources FAILED
**FAILURE**: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-image-picker:processReleaseResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 5.653 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html**
i tried android.enableAapt2=false in gradle.properties of react-native-image-picker but no gain...same error
plz help to resolve it!
Be sure to follow the instructions of the library, after running yarn add react-native-photo-upload
, you need to make sure to link the package and build the project again:
react-native link react-native-image-picker
react-native link react-native-image-resizer
react-native link react-native-fs
After that, you can go to yourProject/android/settings.gradle and verify if all modules have been added. It may look like:
include ':module-name'
project(':module-name').projectDir = new File(rootProject.projectDir,
'../node_modules/module-name/android')
You may also go to yourProject/android/app/build.gradle to check if the modules are present on the dependencies:
dependencies {
compile project(':module-name')
}

Categories

Resources