React Native - react-native-reanimated:compileDebugJavaWithJavac FAILED - java

I just clone a new React Native project. And though I tried many stack overflow solutions, even though those weren't helpful to me, I am still receiving this error while executing this.
followed these solution but those not helpful from stack overflow
npx jetify
cd android && ./gradlew clean
rm -rf node_modules && yarn install && react-native run-android
node version
$ node --version
v14.17.0
java version
java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)
gradle version
------------------------------------------------------------
Gradle 6.7.1
------------------------------------------------------------
Build time: 2020-11-16 17:09:24 UTC
Revision: 2972ff02f3210d2ceed2f1ea880f026acfbab5c0
Kotlin: 1.3.72
Groovy: 2.5.12
Ant: Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM: 1.8.0_202 (Oracle Corporation 25.202-b08)
OS: Windows 10 10.0 amd64
package.json versions
"react": "16.13.1",
"react-native": "0.63.4",
"react-native-reanimated": "2.9.1",
Here i paste error message
> Configure project :react-native-reanimated
No AAR for react-native-reanimated found. Attempting to build from source.
Native libs debug enabled: false
Android gradle plugin: 4.1.1
Gradle: 6.7.1
building Reanimated2
The Kotlin Gradle plugin was loaded multiple times in different subprojects, which is not supported and may break the build.
This might happen in subprojects that apply the Kotlin plugins with the Gradle 'plugins { ... }' DSL if they specify explicit versions, even if the versions are equal.
Please add the Kotlin plugin to the common parent project or the root project, then remove the versions in the subprojects.
If the parent project does not need the plugin, add 'apply false' to the plugin line.
See: https://docs.gradle.org/current/userguide/plugins.html#sec:subprojects_plugins_dsl
The Kotlin plugin was loaded in the following projects: ':react-native-pager-view', ':react-native-webview'
> Task :react-native-reanimated: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.7.1/userguide/command_line_interface.html#sec:command_line_warnings
341 actionable tasks: 2 executed, 339 up-to-date
C:\Users\demo\Desktop\project\node_modules\react-native-reanimated\android\src\main\java\com\swmansion\reanimated\layoutReanimation\ReanimatedUIImplementation.java:13: error: cannot find symbol
ViewManagerResolver viewManagerResolver,
^
symbol: class ViewManagerResolver
location: class ReanimatedUIImplementation
C:\Users\demo\Desktop\project\node_modules\react-native-reanimated\android\src\main\java\com\swmansion\reanimated\layoutReanimation\ReanimatedUIImplementation.java:11: error: recursive constructor invocation
public ReanimatedUIImplementation(
^
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
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-reanimated: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 12s
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

Related

react native android Task :expo-modules-core:compileDebugKotlin FAILED

During the build process using npx react-native run-android I get the following error:
> Task :expo-modules-core:compileDebugKotlin FAILED
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
Execution optimizations have been disabled for 1 invalid unit(s) of work during this build to ensure correctness.
Please consult deprecation warnings for more details.
681 actionable tasks: 665 executed, 16 up-to-date
e: java.lang.NoClassDefFoundError: Could not initialize class org.jetbrains.kotlin.com.intellij.pom.java.LanguageLevel
at org.jetbrains.kotlin.com.intellij.core.CoreLanguageLevelProjectExtension.<init>(CoreLanguageLevelProjectExtension.java:26)
...
About my project:
It was 1st developed using expo sdk, then ejected (by other developer), I cloned the repo on my local machine and tried the following steps to build and run the app:
git glone https://...
cd repo
git checkout -b my_feature_branch
yarn cache clean
yarn install
npx react-native run-android
Then after these steps, I got some build errors but I resolved them, next, I encountered the build error (mentioned above), to solve this I tried the following solution https://stackoverflow.com/a/70675546/11685381 but no luck, I'm still stuck with this error, it's been 3 days since I'm stuck.
My config:
OS: Ubuntu 20.04
local.properties:
sdk.dir = /home/user/Android/Sdk
ndk.dir = /home/user/Android/Sdk/ndk
java --version
java version "17.0.1" 2021-10-19 LTS
Java(TM) SE Runtime Environment (build 17.0.1+12-LTS-39)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12-LTS-39, mixed mode, sharing)
gradle version in project/android/gradle/wrapper/gradle-wrapper.properties => gradle-7.3-all.zip
Can someone please help me out here? Thanks in advance!

How to solve Gradle or Android Studio installation error on an Ionic app

I'm trying to upgrade my Ionic Android APP with new functionalities but get an error
Run $ ionic cordova build android --prod
cordova build android --release
Generating initial manifest for Ionic Deploy...
Ionic Deploy initial manifest successfully generated.
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=/albertosanmartinmartinez/Library/Android/sdk/tools/bin/platform-tools/emulator/build-tools/29.0.0-rc2/zipalign (recommended setting)
ANDROID_HOME=/Users/albertosanmartinmartinez/Library/Android/sdk (DEPRECATED)
Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle
in your path, or install Android Studio
[ERROR] An error occurred while running subprocess cordova.
cordova build android --release exited with exit code 1.
Run $ brew info gradle
gradle: stable 6.8.1
Open-source build automation tool based on the Groovy and Kotlin DSL
https://www.gradle.org/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/gradle.rb
License: Apache-2.0
==> Dependencies
Required: openjdk ✘
==> Analytics
install: 65,592 (30 days), 151,847 (90 days), 558,625 (365 days)
install-on-request: 64,753 (30 days), 150,185 (90 days), 546,096 (365 days)
build-error: 0 (30 days)
Reinstall $ brew install gradle and export it export PATH=$PATH:/usr/local/Cellar/gradle/gradle-7.0.2/bin
And we rerun $ ionic cordova build android --prodhrow new error
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:stripDebugDebugSymbols'.
No version of NDK matched the requested version 21.0.6113669. Versions available locally: 20.0.5594570
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
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.5/userguide/command_line_interface.html#sec:command_line_warnings
38 actionable tasks: 2 executed, 36 up-to-date
Command failed with exit code 1: /Users/.../platforms/android/gradlew cdvBuildDebug -b /Users/.../platforms/android/build.gradle
Anybody could help me please ?
Thanks in advance.

gradle 4.9 - gradlew and java 10 still get: Could not determine java version from '10'

gradlew seems to still have problems with java 10 (please see below).
i remove gradlew/, do a gradle wrapper with 4.9, and try a gradlew -v, i get some warnings and: Could not determine java version from '10'.
does anyone have a workaround?
edit: the gradle-wrapper properties says:
D:\ray\dev\conradapps\rabbit\gradle\wrapper>cat gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
but i just created that with 4.9, so i am confused :(
edit2: #Aris suggested looking at the build file and sure enough, i have a "task wrapper(type: Wrapper) { gradleVersion = '2.14' }" in there.
edit3: removing the wrapper task from the build file and creating another by doing a gradle wrapper works fine!
java version reports:
D:\ray\dev\conradapps\rabbit>java -version
java version "10" 2018-03-20
Java(TM) SE Runtime Environment 18.3 (build 10+46)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10+46, mixed mode)
D:\ray\dev\conradapps\rabbit>java --version
java 10 2018-03-20
Java(TM) SE Runtime Environment 18.3 (build 10+46)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10+46, mixed mode)
D:\ray\dev\conradapps\rabbit>
D:\ray\dev\conradapps\rabbit>gradle -v
Welcome to Gradle 4.9!
Here are the highlights of this release:
- Experimental APIs for creating and configuring tasks lazily
- Pass arguments to JavaExec via CLI
- Auxiliary publication dependency support for multi-project builds
- Improved dependency insight report
For more details see https://docs.gradle.org/4.9/release-notes.html
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass
(file:/D:/dev/gradle-4.9/lib/groovy-all-2.4.12.jar) to method java.lang.Object.
finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groov
y.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflect
ive access operations
WARNING: All illegal access operations will be denied in a future release
------------------------------------------------------------
Gradle 4.9
------------------------------------------------------------
Build time: 2018-07-16 08:14:03 UTC
Revision: efcf8c1cf533b03c70f394f270f46a174c738efc
Kotlin DSL: 0.18.4
Kotlin: 1.2.41
Groovy: 2.4.12
Ant: Apache Ant(TM) version 1.9.11 compiled on March 23 2018
JVM: 10 ("Oracle Corporation" 10+46)
OS: Windows 8.1 6.3 amd64
D:\ray\dev\conradapps\rabbit>ls -F
165705.JPG* getalllogfiles.bat* loggger.dtd*
IMG_2708.jpg* getlogfiles.bat* pull.bat*
bin/ gradle/ run.bat*
build/ gradlew* runlogserver.bat*
build.gradle* gradlew.bat* save/
chainsaw.bat* here.sh* settings.gradle*
chainsawconfig.xml* histories.WinMerge* src/
controller.bat* jlogviewer_1_0_0d.jar* t1.bat*
deleteemptylogfiles.sh* junk.bat* testpb.bat*
deletelogfiles.bat* lib/ tmp.jar*
eyedocs.jpg* listalllogfiles.bat*
filterLogs.sh* log/
D:\ray\dev\conradapps\rabbit>rm -r gradle/
D:\ray\dev\conradapps\rabbit>gradle wrapper
Starting a Gradle Daemon (subsequent builds will be faster)
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.9/userguide/command_line_interface.html#sec:comman
d_line_warnings
BUILD SUCCESSFUL in 30s
1 actionable task: 1 executed
D:\ray\dev\conradapps\rabbit>gradlew -v
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '10'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
D:\ray\dev\conradapps\rabbit>
Even though you upgraded your local Gradle distribution to a new version, the one used by your gradle wrapper was still very old, meaning it was not supporting new Java versions. This is evident by your gradlew.properties file and the build.gradle wrapper task's version.
Fixing the gradle wrapper task's gradle version should fix this. You should then be able to re-run the wrapper task and create a correct wrapper.

Gradle 4.8.1 - Could not determine java version from '9.0.1' error

I have noticed this issue has been extensively asked and 'solved' for someone but I cannot get it to work on my machine.
I am using cordova to build an Android App - as soon as I run "cordova build android" I get this output:
ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk-9.0.1
studio
BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed
Subproject Path: CordovaLib
Subproject Path: app
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '9.0.1'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --
debug option to get more log output.
* Get more help at https://help.gradle.org
Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '9.0.1'.
* Try:
Run with --stacktrace option to get the stack trace.
* Get more help at https://help.gradle.org
Grande -v:
------------------------------------------------------------
Gradle 4.8.1
------------------------------------------------------------
Build time: 2018-06-21 07:53:06 UTC
Revision: 0abdea078047b12df42e7750ccba34d69b516a22
Groovy: 2.4.12
Ant: Apache Ant(TM) version 1.9.11 compiled on March 23 2018
JVM: 9.0.1 (Oracle Corporation 9.0.1+11)
OS: Windows 10 10.0 amd64
Java -version:
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
In some of the post I have seen, they had a really old version of Gradle and mine is the latest.
Any straight forward fix for that?
That's a bug on Cordova not correctly detecting the java version as it expect it to be in the form of 1.x (i.e. 1.9) and not 9.
Anyway, java 9 is not supported, you have to downgrade the JDK to java 8 as it's required by Android.

why is my gradle build failing but gradlew build is successsful?

I have a gradle project that I am trying to build.
when I execute gradle clean build, it fails with the following error message
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':FacebookUpdateDependencies'.
> Could not resolve all dependencies for configuration ':compiler'.
> Could not resolve com.company.facebook:compiler:1.2+.
Required by:
::1.0
> Could not resolve com.company.facebook:compiler:1.2+.
> Failed to list versions for com.company.facebook:compiler.
> Unable to load Maven meta-data from http://mycompanynexus/compiler/maven-metadata.xml.
> Could not GET 'http://mycompanynexus/compiler/maven-metadata.xml'. Received status code 500 from server: Internal Server Error
However, when I tried
./gradlew clean build the build is successful.
why the build fails in the former and not the latter?
here is revelant portion of build.gradle
task wrapper(type: Wrapper) {
gradleVersion = '2.11'
}
EDIT
local$: gradle -v
------------------------------------------------------------
Gradle 2.13
------------------------------------------------------------
Build time: 2016-04-25 04:10:10 UTC
Build number: none
Revision: 3b427b1481e46232107303c90be7b05079b05b1c
Groovy: 2.4.4
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.7.0_79 (Oracle Corporation 24.79-b02)
OS: Mac OS X 10.11.1 x86_64
local$ ./gradlew -v
------------------------------------------------------------
Gradle 1.12
------------------------------------------------------------
Build time: 2014-04-29 09:24:31 UTC
Build number: none
Revision: a831fa866d46cbee94e61a09af15f9dd95987421
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
Ivy: 2.2.0
JVM: 1.7.0_79 (Oracle Corporation 24.79-b02)
OS: Mac OS X 10.11.1 x86_64
I just noticed that the wrapper version is 1.12 and not 2.12. That is, there is a very large version difference between the wrapper and the installed version of gradle. There have probably been many incompatible changes to the different gradle plugins over the last 2 years, which may lead to the build problems you observe.
As already mentioned the gradle wrapper is a separate version of gradle that resides in the gradle/wrapper folder of your project. The wrapper is only built/updated, when executing the wrapper task in your project (gradle wrapper). That is your project's wrapper has not been updated for the last 2 years or has been created with the wrong version initially (1.12 instead of 2.11).
Given the above it's hard the tell what is actually causing the build to fail - apart from the incompatibilities between gradle 1.12 and 2.13. But this version mismatch is probably the root cause of your problem.
Most likely your project won't built anymore using the wrapper once you regenerated the wrapper with version 2.11 (the version mentioned in the build file), as 2.11 is likely to be incompatible to 1.12 as well...
This tells you that your Gradle version 2.11 will be used when gradlew command is invoked instead of the one installed on system. Always run gradlew command as it ensures your build is run against the gradle version it is supposed to, you are never required to install the correct version of gradle and really speeds up the build time.
Here is an excerpt from Gradle Wrapper definition:
Most tools require installation on your computer before you can use them. If the installation is easy, you may think that’s fine. But it can be an unnecessary burden on the users of the build. Equally importantly, will the user install the right version of the tool for the build? What if they’re building an old version of the software?
The Gradle Wrapper (henceforth referred to as the “Wrapper”) solves both these problems and is the preferred way of starting a Gradle build.
If a Gradle project has set up the Wrapper (and we recommend all projects do so), you can execute the build using one of the following commands from the root of the project:
./gradlew (on Unix-like platforms such as Linux and Mac OS X)
gradlew (on Windows using the gradlew.bat batch file)
Each Wrapper is tied to a specific version of Gradle, so when you first run one of the commands above for a given Gradle version, it will download the
corresponding Gradle distribution and use it to execute the build.

Categories