Execution failed for task ':react-native-pjsip:compileReleaseJavaWithJavac' - react-native

I'm trying to build a react-native project cloned from github. Here is the github project.
After npm install. I tried the react-native run-android and I got this:
/var/www/html/test/sipsip/react-native-pjsip-app/node_modules/react-native-pjsip/android/src/main/java/com/carusto/ReactNativePjSip/PjSipModulePackage.java:12: error: PjSipModulePackage is not abstract and does not override abstract method createJSModules() in ReactPackage
public class PjSipModulePackage implements ReactPackage {
^
/var/www/html/test/sipsip/react-native-pjsip-app/node_modules/react-native-pjsip/android/src/main/java/com/carusto/ReactNativePjSip/PjActions.java:307: error: cannot find symbol
value.put(mapKey, map.getArray(mapKey).toArrayList());
^
symbol: method toArrayList()
location: interface ReadableArray
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
:react-native-pjsip:compileReleaseJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-pjsip:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* 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: 24.355 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/android-setup.html
I've tried many solutions but none of them solved my issue. Do you have any idea how to fix this?
Additional info:
react-native version:
react-native-cli: 2.0.1
react-native: 0.41.2

I was facing the same problem today, and was solved just updating my react-native in the project using
react-native-git-upgrade
If you don't have it installed yet (the upgrader), you can call
npm install -g react-native-git-upgrade
Of course, there were some thousands of graddles to update, and .js files failing (Still working on it), but at least, I've passed the failure you described.

Delete /ios and /android folders
Then run react-native eject

Related

Getting the error while starting react-native project

I am beginner in react-native. While building my app for android, I am getting this error
Task :react-native-community_toolbar-android:compileDebugJavaWithJavac FAILED
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.2/userguide/command_line_interface.html#sec:command_line_warnings
39 actionable tasks: 39 executed
Note: /home/kanhaiya/testapp/node_modules/#react-native-community/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStorageModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
/home/kanhaiya/testapp/node_modules/#react-native-community/toolbar-android/android/src/main/java/com/reactnativecommunity/toolbarandroid/ReactToolbar.java:107: error: IconImageInfo is not abstract and does not override abstract method getExtras() in HasImageMetadata
private static class IconImageInfo implements ImageInfo {
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':react-native-community_toolbar-android:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
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 25s
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
Note: /home/kanhaiya/testapp/node_modules/#react-native-community/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStorageModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
/home/kanhaiya/testapp/node_modules/#react-native-community/toolbar-android/android/src/main/java/com/reactnativecommunity/toolbarandroid/ReactToolbar.java:107: error: IconImageInfo is not abstract and does not override abstract method getExtras() in HasImageMetadata
private static class IconImageInfo implements ImageInfo {
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':react-native-community_toolbar-android:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
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 25s
at makeError (/home/kanhaiya/testapp/node_modules/execa/index.js:174:9)
at /home/kanhaiya/testapp/node_modules/execa/index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async runOnAllDevices (/home/kanhaiya/testapp/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
at async Command.handleAction (/home/kanhaiya/testapp/node_modules/react-native/node_modules/#react-native-community/cli/build/index.js:192:9)
I have already linked react-native-community/toolbar-android in my project using react-native link #react-native-community/toolbar-android. Still it is giving error.
There are few steps, you can follow up, and see if things are working.
FIRST WAY:
cd Android && cd ./gradlew clean
Please note: ./gradlew <follow_by_script_command> for MacOS. For Windows, just do gradlew <follow_by_script_command>.
If you want to generate a bundle, then do this after the above commands:
./gradlew :app:bundleRelease
SECOND WAY:
Possible reason of this error is your RN version might be different from Android's build.gradle version which android/app/build.gradle. When you create a react-native app probably it create android app like:
implementation "com.facebook.react:react-native:+"
Try inspecting your node_modules folder, look for react-native folder and look for a folder with a number, that numbers are react-native version. For me it's 0.66.4 then update android/app/build.gradle:
implementation "com.facebook.react:react-native:0.66.4"
after running yarn upgrade #react-native-community/toolbar-android#^0.2.1, the problem is gone.If you are using npm then update the package to the latest.Happy Coding :)

Error when trying to use React Native Keychain

I am trying to use React Native Keychain in my app.
I just install it yarn add react-native-keychain and then run yarn run android and get this error:
> Task :react-native-keychain:compileDebugJavaWithJavac FAILED
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.0.1/userguide/command_line_interface.html#sec:command_line_warnings
83 actionable tasks: 80 executed, 3 up-to-date
Note: /home/david/Desktop/Encarti/encarti-mobile-app-worker/node_modules/#react-native-community/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStorageModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/david/Desktop/Encarti/encarti-mobile-app-worker/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
/home/david/Desktop/Encarti/encarti-mobile-app-worker/node_modules/react-native-keychain/android/src/main/java/com/oblador/keychain/DeviceAvailability.java:30: error: cannot find symbol
return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE);
^
symbol: variable FEATURE_FACE
location: class PackageManager
/home/david/Desktop/Encarti/encarti-mobile-app-worker/node_modules/react-native-keychain/android/src/main/java/com/oblador/keychain/DeviceAvailability.java:34: error: cannot find symbol
return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_IRIS);
^
symbol: variable FEATURE_IRIS
location: class PackageManager
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-keychain:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* 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
I saw this post: Compilation failed (android) after installation of react-native-keychain and tried the solution there but it still fails. How can I fix this problem?
share your code is more efficient :)
https://github.com/oblador/react-native-keychain/issues/351#issuecomment-640788608
Try this :
compileSdkVersion = 29

Task :react-native-auth0:compileDebugJavaWithJavac FAILED after installing react-native-azurenotificationhub

In my React Native app everything was working fine up until I decided to implement react-native-azurenotificationhub to connect my app to Azure Notifications Hub.
My app uses Auth0 for user authentication and up until now, I didn’t have any issues with it.
I’m on the latest version of all the packages, including React Native 0.63.1
I followed the instructions here to install the Azure Notifications Hub package and that’s when all the problems started https://github.com/CatalystCode/react-native-azurenotificationhub/blob/master/docs/android-installation.md
Now, I'm getting the following error:
> Configure project :app
WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getMergeResources(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
> Task :react-native-auth0:compileDebugJavaWithJavac FAILED
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.2/userguide/command_line_interface.html#sec:command_line_warnings
42 actionable tasks: 2 executed, 40 up-to-date
C:\Users\sam\source\repos\iQuest\Ingrid Mobile\Time\ingridtime\node_modules\react-native-auth0\android\src\main\java\com\auth0\react\A0Auth0Package.java:13: error: A0Auth0Package is not abstract and does not override abstract method createJSModules() in ReactPackage
public class A0Auth0Package implements ReactPackage {
^
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-auth0:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* 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. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
C:\Users\sam\source\repos\iQuest\Ingrid Mobile\Time\ingridtime\node_modules\react-native-auth0\android\src\main\java\com\auth0\react\A0Auth0Package.java:13: error: A0Auth0Package is not abstract and does not override abstract method createJSModules() in ReactPackage
I've been researching this for the last two days and answers are all over the place and I practically tried all of them to no avail. Any idea what's going on here?

Cannot run the project after setting up react-native-firebase

Basically what I'm asking is if anyone knows how to install react-native-firebase and connect the project to firebase? It should be very easy but it's not working.
I'm using the docs here:
https://rnfirebase.io/#2-android-setup
But I'm installing react-native-firebase instead of react-native-firebase/app because I would like to use react-native-firebase SDK
I'm creating a new project using
npx react-native init newProject
then install the package:
npm install --save react-native-firebase
Then I create a new frebase project, add the google-services.json to the app folder, and add the module:
classpath 'com.google.gms:google-services:4.3.3'
(Android studio suggests using the latest version)
And:
apply plugin: 'com.google.gms.google-services'
After that I cannot run the project anymore.
It's stuck:
C:\Users\Omer\react-native1\haveri>npx react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1034 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
info Installing the app...
> Configure project :react-native-firebase
react-native-firebase: using React Native prebuilt binary from C:\Users\Omer\react-native1\haveri\node_modules\react-native\android
> Task :app:stripDebugDebugSymbols UP-TO-DATE
Compatible side by side NDK version was not found.
<============-> 99% EXECUTING [1m 11s] > IDLE > IDLE > IDLE > IDLE > IDLE > :app:installDebug
> IDLE
> IDLE
If I'm using the version as indicated in the docs:
classpath 'com.google.gms:google-services:4.2.0'
I'm getting this error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Unable to delete directory 'C:\Users\Omer\react-native1\haveri\android\app\build\generated\not_namespaced_r_class_sources\debug\r\androidx' after 10 attempts
* 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 15s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Unable to delete directory 'C:\Users\Omer\react-native1\haveri\android\app\build\generated\not_namespaced_r_class_sources\debug\r\androidx' after 10 attempts
* 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 15s
at makeError (C:\Users\Omer\react-native1\haveri\node_modules\execa\index.js:174:9)
at C:\Users\Omer\react-native1\haveri\node_modules\execa\index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async runOnAllDevices (C:\Users\Omer\react-native1\haveri\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)
at async Command.handleAction (C:\Users\Omer\react-native1\haveri\node_modules\react-native\node_modules\#react-native-community\cli\build\index.js:186:9)
This is all trying to install the react-native-firebase on a brand new project.
What am I doing wrong? How can I install it successfully?
Try running these commands. Then start try to run your app again
cd android
./gradlew clean
Try building Gradle from within Android studio. I found that this overcame some build problems sometimes when integrating with react-native-firebase. From Android studio, open your android project by navigating to your /Android folder in your RN project. Let Gradle start syncing and monitor for any errors details.
You may find that there are some JDK path related issues when launching your Android Studio. Try to troubleshoot any errors reported by Android Studio before building.

Execution failed for task processDebugResources

when you try to run the command:
react-native run-android
the following error occurs:
> Task :react-native-gesture-handler:compileDebugJavaWithJavac
Note: C:\Users\jefer\Desktop\react\new\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerButtonViewManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
> Task :app:processDebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Package 'com.new' from AndroidManifest.xml is not a valid Java package name as 'new' is a Java keyword.
* 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 23s
23 actionable tasks: 21 executed, 2 up-to-date
error 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
error Command failed: gradlew.bat app:installDebug
I've tried using:
cd android && gradlew clean
but it did not solve the problem ... I also deleted the android and iOS folders and used the commands:
react-native eject
react-native link
but it did not work.
Problem with your application package name
You set app package name is com.new in AndroifManifest.xml is not a valid package name. Change application package name because new is reserved keyword in java