Task :react-native-screens:compileDebugJavaWithJavac FAILED - react-native

Im using react navigation v5.. installed all the dependencies.. now Im getting above error..
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-screens:compileDebugJavaWithJavac'.
> java.lang.reflect.UndeclaredThrowableException
* 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.5/userguide/command_line_interface.html#sec:command_line_warnings

Run this command in your terminal
cd android
// to check if there are any deamon running.
./gradlew --status or .\gradlew --status
./gradlew --stop
./gradlew clean
cd ..
// then restart the server

I think this issue is still open on GitHub issues -> View
If your React Native Version < 0.60 then you can use Jetifier to solve this issue
How to use Jetifier to solve ?
yarn add --dev jetify
Then in your package.json scripts add:
"postinstall": "jetify"
yarn jetify
If your React Native Version 0.60 > then try this
cd android && ./gradlew clean

it do it when you upgrade your react-native version to 0.69.1 or higher insert the kotlin classpath to build.gradle of app(android\build.gradle) :
dependencies {
.....
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10") ----- this line
.....
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
sorry for my english

Related

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.

React Native - Async Storage error when run react-native run-android

I'm trying to run react-native run-android but receive the following error:
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
D:\Work\CS\Wms-Mobile\CS-WmsMobile\node_modules\#react-native-community\async-storage\android\src\main\java\com\reactnativecommunity\asyncstorage\AsyncStorageModule.java:26: error: package com.facebook.react.module.annotations does not exist
import com.facebook.react.module.annotations.ReactModule;
^
D:\Work\CS\Wms-Mobile\CS-WmsMobile\node_modules\#react-native-community\async-storage\android\src\main\java\com\reactnativecommunity\asyncstorage\AsyncStorageModule.java:34: error: cannot find symbol
#ReactModule(name = AsyncStorageModule.NAME)
^
symbol: class ReactModule
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-community_async-storage: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 1m 16s
at checkExecSyncError (child_process.js:621:11)
at execFileSync (child_process.js:639:15)
at runOnAllDevices (D:\Work\CS\Wms-Mobile\CS-WmsMobile\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Things I've tried:
Reinstall node_modules
cd ./android and then ./gradlew clean
But none of them seems to work. I am glad to hear your suggestion, thank you in advance!
My version:
react-native-cli: 2.0.1
react-native: 0.61.4
android gradle plugin: 3.5.3
gradle: 5.4.1
Try with below command
react-native link #react-native-community/async-storage
feel free for doubts
Try the following solutions.
Uninstall Node Modules
Clean Gradle (cd android && gradlew clean)
now install back your modules (yarn install)
if this does not help try upgrading your packages.
yarn upgrade --pattern react-native
Open the AVD Manager and try to start your phone emulator with Cold Boot, then close all applications. Clean and compile your application again, it must work now.
Sometimes even when you clean your application, your emulator get stuck.
Annotations usually has something to do with Jetpack migrations
Try using this Jetifier tool
Just make sure to run npx jetify at the project root.
Using sudo solved the issue in my case. sudo react-native ..., sudo ./gradlew ... etc.
You can try to add this to your android/build.gradle file
allprojects {
repositories {
exclusiveContent {
// We get React Native's Android binaries exclusively through npm,
// from a local Maven repo inside node_modules/react-native/.
// (The use of exclusiveContent prevents looking elsewhere like Maven Central
// and potentially getting a wrong version.)
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
// NOTE: if you are in a monorepo, you may have "$rootDir/../../../node_modules/react-native/android"
url "$rootDir/../node_modules/react-native/android"
}
}
}
mavenCentral()
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../../../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../../../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}

I can't open an existing react-native project

I get the following error when I run this command
react-native run-android
Configure project :react-native-onesignal
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed soon. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: Configuration 'testCompile' is obsolete and has been replaced with 'testImplementation'.
It will be removed soon. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Configure project :react-native-webview
:react-native-webview:reactNativeAndroidRoot C:\Users\VO\Desktop\xxxx\xxxx\node_modules\react-native\android
FAILURE: Build failed with an exception.
What went wrong:
Task installDebug' not found in project ':app'.
Try:
Run gradlew tasks to get a list of available tasks. 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
BUILD FAILED in 4s
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. Run CLI with --verbose flag for more details.
First check these:
Check that you have installed all your dependencies correctly or not.
react-native-webview and other plugins giving error then try to fix it.
Gradle version are important for specific plugin usage so check it also that you are using supported Gradle version.
Follow these steps:
Close all metro bundles
watchman watch-del-all && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
open Android Studio and open yourprojectname/android
Let Android Studio sync and if there any sync issue then fix it.
Go to File menu -> invalidate cache and restart
Before react-native run-android try to check you have open device or emulator
Check it with adb devices
Now try once.

Failed to build react native app after linking with ble-plx

react-native run-android failed after linking with react-native-ble-plx
Task :react-native-ble-plx:compileDebugJavaWithJavac FAILED
This is a newly created app with react-native init, didn't change anything except the min sdk.
Already tried to clean project, set min sdk to 18, tried to build with android studio to get more specific error but still can't understand where is the problem coming from.
The Error i get:
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
12 actionable tasks: 2 executed, 10 up-to-date
warning: [options] source value 7 is obsolete and will be removed in a future release
warning: [options] target value 7 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
/Users/oriamd/Documents/MyDev/DudeWheresMyCar/node_modules/react-native-ble-plx/android/src/main/java/com/polidea/reactnativeble/converter/RxBleScanResultConverter.java:3: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
^
/Users/oriamd/Documents/MyDev/DudeWheresMyCar/node_modules/react-native-ble-plx/android/src/main/java/com/polidea/reactnativeble/wrapper/Characteristic.java:5: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
^
full logs here :
https://pastebin.com/NJAmjUJm
Can supply more information if needed.
Thank you
This issue is similar to this issue.
As mentioned in #Kreator answer it is related to some packages that are not converted to AndroidX.
To fix this issue you can use jetifier.
I have the same issue mentioned in the question and these steps solved it and application run again.
First, use Android Studio's refactoring tool to convert your app re: the Android developer docs
npm install --save-dev jetifier
npx jetify
npx react-native run-android (your app should correctly compile and work)
Call npx jetify run in the postinstall target of your package.json (Any time your dependencies update you have to jetify again)
Problem was that i was using Android Studio Preview, and with that AndroidX and more unsupported packages.
I HAD THIS SAME ISSUE.
"Task :react-native-ble-plx:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task
':react-native-ble-plx: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 54s
error Failed to install the app. Make sure you have the Android
development environment set up:
https://reactnative.dev/docs/environment-setup.
Solution
this was my build.gradle project:
buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
ndkVersion = "21.4.7075529"
kotlin_version = "1.6.0" // Update this to your version
}
repositories {
google()
mavenCentral()
}
...
}
I changed the some version to as following:
compileSdkVersion = 29
targetSdkVersion = 29
And now the Build is successful!

React-Native Android Gradlew installDebug results in build failure

I am running a React-Native app but when I try to gradlew installDebug in the android directory I get a build failure. Here is the info I get when I use:
gradlew installDebug --info
`BUILD FAILED
Total time: 1.118 secs
Stopped 0 compiler daemon(s).
Received result CommandFailure[value=org.gradle.launcher.exec.ReportedException: org.gradle.internal.exceptions.LocationAwareException: A problem occurred configuring project ':app'.] from daemon DaemonInfo{pid=4326, address=[4c8a3b8f-5957-4911-b262-0e36824d2139 port:54258, addresses:[/0:0:0:0:0:0:0:1, /127.0.0.1]], idle=true, context=DefaultDaemonContext[uid=dbec8c34-89ba-4872-9077-12b4b3ff38a0,javaHome=/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home,daemonRegistryDir=/Users/d0ntg0m0ng/.gradle/daemon,pid=4326,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]}.`
This is the error I get when I run gradlew installDebug without --info
`android [router] :> ./gradlew installDebug
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring project ':app'.
Cannot evaluate module react-native-couchbase-lite : Configuration with name 'default' not found.`
"react-native": "^0.15.0", is the version of react-native I am using.
this is the repo that the project is fork from
I am trying to setup the app to my genymotion emulator but the build never finishes.
I have already run the commands to react-native start and set up the sync to the couchbase lite server. Not sure if this is relevant info. I am fairly new to native development and I have no idea where to start with trying to debug this.
include ':app'
include ':react-native-couchbase-lite'
project(':react-native-couchbase-lite').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-couchbase-lite/android')
check the file path