sudo react-native run-android giving error - react-native

I have no idea what is the error when i want to run my react native app.
info Starting JS server...
info Installing the app...
> Task :app:processDebugManifest FAILED
See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
10 actionable tasks: 3 executed, 7 up-to-date
/var/www/html/react/LotteryApp/android/app/src/debug/AndroidManifest.xml:22:18-91 Error:
Attribute application#appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.1] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:7:5-117 to override.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application#appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.1] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:7:5-117 to override.
* 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 5s
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
/var/www/html/react/LotteryApp/android/app/src/debug/AndroidManifest.xml:22:18-91 Error:
Attribute application#appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.1] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:7:5-117 to override.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application#appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.1] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:7:5-117 to override.
* 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 5s
at checkExecSyncError (child_process.js:629:11)
at execFileSync (child_process.js:647:13)
at runOnAllDevices (/var/www/html/react/LotteryApp/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:75:39)
at buildAndRun (/var/www/html/react/LotteryApp/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/index.js:137:41)
at then.result (/var/www/html/react/LotteryApp/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/index.js:103:12)
at process._tickCallback (internal/process/next_tick.js:68:7)
It was working fine yesterday. I can't understand on the above code. What kind of error is this ? Please help on this. I tied to find on google. But cant find anything. Thanks in advance.

Did you build the app with Android studio once?
If not, build it first in Android Studio and install it through Android Studio.
To Build the app in android studio:
Open Android Studio.
Open react_native_project/android with Android Studio.
Wait for all it to build automatically, if some errors are present, try running Build > Clean Build.
Gradle should build successfully.
Then try:react-native run-android.
If it still does not work, stop the process and then run react-native start -- --reset-cache

Related

react-native-appearance make a gradle error

Hey i have a error with gradle on my react native app (when i run yarn android)
yarn run v1.22.17
$ react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 980 file(s) to forward-jetify. Using 32 workers...
info JS server already running.
info Installing the app...
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.2/userguide/command_line_interface.html#sec:command_line_warnings
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Build file 'C:\Users\user\Documents\project react native\appfirst\node_modules\react-native-appearance\android\build.gradle' line: 23
* What went wrong:
A problem occurred evaluating project ':react-native-appearance'.
> Plugin with id 'maven' not found.
* 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 ':react-native-appearance'.
> com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle
* 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 6s
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.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Build file 'C:\Users\user\Documents\project react native\appfirst\node_modules\react-native-appearance\android\build.gradle' line: 23
* What went wrong:
A problem occurred evaluating project ':react-native-appearance'.
> Plugin with id 'maven' not found.
* 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 ':react-native-appearance'.
> com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle
* 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 6s
at makeError (C:\Users\roro3\Documents\project react native\appfirst\node_modules\execa\index.js:174:9)
at C:\Users\roro3\Documents\project react native\appfirst\node_modules\execa\index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (C:\Users\roro3\Documents\project react native\appfirst\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
at async Command.handleAction (C:\Users\roro3\Documents\project react native\appfirst\node_modules\#react-native-community\cli\build\index.js:192:9)
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I see a error with react-native-appearance but i don't understand why.
I got this error after instalation of some package (react-native-gesture-handler react-native-reanimated react-native-screens react-native-safe-area-context #react-native-community/masked-view)
I also got into some problems with the react-native-appearence package. If you use expo you shouldn't have this problem or just update the package to version 0.3.4.
If you use use the react-native-cli the only option for you is to downgrade your react-native to a version which is using Gradle 6. You can find more information here about this issue.

macbook m1: error Failed to launch emulator

I use macbook m1 and set sdk in android studio.
I follow all the process: https://reactnative.dev/docs/environment-setup.
But I couldn't understand above process.
when I run this command line from terminal. It says
zsh: command not found: sdkmanager
So I pass that process.
Except for that, I installed all as doc says.
But when I run npx react-native run-android.
Error message below appears.
what is the problem?
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/Users/hayat/Documents/AwesomeProject/android/local.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 3s
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.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/Users/hayat/Documents/AwesomeProject/android/local.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 3s
at makeError (/Users/hayat/Documents/AwesomeProject/node_modules/execa/index.js:174:9)
at /Users/hayat/Documents/AwesomeProject/node_modules/execa/index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (/Users/hayat/Documents/AwesomeProject/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
at async Command.handleAction (/Users/hayat/Documents/AwesomeProject/node_modules/#react-native-community/cli/build/index.js:192:9)
info Run CLI with --verbose flag for more details.
Running android emulator on m1 chip requires extra installation steps.
I recommend you to watch this video which might be helpful to your situation.
See this also.

Failed to create Jar file C:\Users\Fasih_khan\.gradle\caches\jars-8\d39c566f673fd9079bc7973003ab0a69\builder-4.2.2.jar

npx react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 982 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
info Installing the app...
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'food_shop'.
Failed to create Jar file C:\Users\Fasih_khan.gradle\caches\jars-8\d39c566f673fd9079bc7973003ab0a69\builder-4.2.2.jar.
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 41s
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.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'food_shop'.
Failed to create Jar file C:\Users\Fasih_khan.gradle\caches\jars-8\d39c566f673fd9079bc7973003ab0a69\builder-4.2.2.jar.
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 41s
at makeError (E:\COURSES\Development\Shop\food_shop\node_modules\execa\index.js:174:9)
at E:\COURSES\Development\Shop\food_shop\node_modules\execa\index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async runOnAllDevices (E:\COURSES\Development\Shop\food_shop\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
at async Command.handleAction (E:\COURSES\Development\Shop\food_shop\node_modules\react-native\node_modules\#react-native-community\cli\build\index.js:192:9)
info Run CLI with --verbose flag for more details.
For me error was like below
GradleException: Failed to create Jar file /root/.gradle/caches/jars-8/da1fb602f5e9c4589f7a774fa11d9312/bin.jar
Solution was : touch /root/.gradle/caches/jars-8/da1fb602f5e9c4589f7a774fa11d9312/bin.jar
If it will help.
I had similar issue but with different jar - spring-core-6.0.3.jar.
It looks like gradle hold a lock on cached files for some reasons while building your food_shop application.
Correct solution is to figure out which daemon process made a lock, then stop it calling gradle --stop and then restart gradle build again.
If it's not helped then check your locked cache files:
gradle --stop
check if lib already exists, it may looks like builder-4.2.2.jar.lock.lock
delete it if so.
run gradle build again for your project.
If you have dozen processes of gradle wrapper and it's difficult to figure out which one locked the file this solution would help.

How to start project on react native

I installed everything on my computer and also set all environment variables of path and android_home but I still got these error please help me to solve my problem. My android studio is also running and the emulator is running too but I don't get what's the problem while running my react native app.
C:\Users\Pandat\Desktop\React\AwesomeProject>npx react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 864 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Installing the app...
Task :app:processDebugManifest FAILED
See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
10 actionable tasks: 2 executed, 8 up-to-date
C:\Users\Pandat\Desktop\React\AwesomeProject\android\app\src\debug\AndroidManifest.xml:7:7-38 Error:
Attribute application#name value=(com.example.app) from AndroidManifest.xml:7:7-38
is also present at AndroidManifest.xml:7:7-38 value=(com.awesomeproject.MainApplication).
Suggestion: add 'tools:replace="android:name"' to element at AndroidManifest.xml:8:5-14:43 to override.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : Attribute application#name value=(com.example.app) from AndroidManifest.xml:7:7-38
is also present at AndroidManifest.xml:7:7-38 value=(com.awesomeproject.MainApplication).
Suggestion: add 'tools:replace="android:name"' to element at AndroidManifest.xml:8:5-14:43 to override.
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 39s
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
C:\Users\Pandat\Desktop\React\AwesomeProject\android\app\src\debug\AndroidManifest.xml:7:7-38 Error:
Attribute application#name value=(com.example.app) from AndroidManifest.xml:7:7-38
is also present at AndroidManifest.xml:7:7-38 value=(com.awesomeproject.MainApplication).
Suggestion: add 'tools:replace="android:name"' to element at AndroidManifest.xml:8:5-14:43 to override.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : Attribute application#name value=(com.example.app) from AndroidManifest.xml:7:7-38
is also present at AndroidManifest.xml:7:7-38 value=(com.awesomeproject.MainApplication).
Suggestion: add 'tools:replace="android:name"' to element at AndroidManifest.xml:8:5-14:43 to override.
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 39s
at checkExecSyncError (child_process.js:610:11)
at execFileSync (child_process.js:628:15)
at runOnAllDevices (C:\Users\Pandat\Desktop\React\AwesomeProject\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
at buildAndRun (C:\Users\Pandat\Desktop\React\AwesomeProject\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\index.js:158:41)
at C:\Users\Pandat\Desktop\React\AwesomeProject\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\index.js:125:12
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Command.handleAction (C:\Users\Pandat\Desktop\React\AwesomeProject\node_modules\react-native\node_modules\#react-native-community\cli\build\index.js:164:9)
May be you should rename your react native app and the project package by using this library
https://www.npmjs.com/package/react-native-rename
npm install react-native-rename
react-native-rename "Travel App" -b com.junedomingo.travelapp
You named your react-native project new ... and this is not a valid name for java-package (cause it is a keyword)...
The very last line of the error message shows
at async Command.handleAction (C:\Users\Pandat\Desktop\React\new\node_modules\react-native\node_modules\#react-native-community\cli\build\index.js:164:9)
You cannot have a keyword in your path name for the project so names like
com.new.project
com.class.sample
etc are not allowed
change your name to something which is not reserved
like C:\Users\Pandat\Desktop\React\sample
use react-native run-android instead of npx react-native run-android it works for me . hope it too will work for you. Fell free to ask for Doubts.

react native Admob is not working android

Task :app:processDebugManifest FAILED
/Users/balwindersingh/Desktop/WEBSITETOON/InstagramUI/InstagramUI/android/app/src/debug/AndroidManifest.xml:22:18-91 Error:
Attribute application#appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:7:5-117 to override.
See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : Attribute application#appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:7:5-117 to override.
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 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings