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!
Related
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
I installed JDK 14 and started using it.
However projects that use Gradle 6.2.2 cannot work, and the following error appears each time I try to invoke a Gradle Task :
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
Other projects, for instance maven projects and plain java projects work OK with Java 14.
An easy way to reproduce this error is by creating a new folder and attempting to run the init task.
For instance:
gradle init --type basic
FAILURE: Build failed with an exception.
What went wrong: Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
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 878ms
The PC that runs this example uses windows 10.
The java version is:
java --version
java 14 2020-03-17 Java(TM) SE Runtime Environment (build 14+36-1461)
Java HotSpot(TM) 64-Bit Server VM (build 14+36-1461, mixed mode,
sharing)
Is there any solution to this problem so that I can make Gradle 6.2.2 work with Oracle JDK 14?
As pointed out in the comments above and in Gradle 6.2.2. Compatibility a Java version between 8 and 13 is required to execute Gradle 6.2.2. Java 14 and later versions are not yet supported by Gradle 6.2.2.
Updated answer since Gradle 6.3 release:
Gradle 6.3, supports JDK 14 According to the Gradle 6.3 Release notes .
The following solutions apply:
To keep using Gradle 6.2.2:
Install a compatible JDK Version (8-13)
Modify gradle.properties to use this version.
For example if JDK 13 is installed in: C:/Program Files/Java/jdk-13.0.2
Make sure the following line is in gradle.properties.
org.gradle.java.home=C:/Program Files/Java/jdk-13.0.2
To Keep using JDK14.
Install and use Gradle 6.3 (or higher)
After setting up your system, verify that you are running the correct versions.
For instance when using Java 14 and Gradle 6.3 you will get something like:
Type C:\>gradle --version following to get the gradle version:
C:>gradle --version
Gradle 6.3
Build time: 2020-03-24 19:52:07 UTC Revision:
bacd40b727b0130eeac8855ae3f9fd9a0b207c60
Kotlin: 1.3.70 Groovy: 2.5.10 Ant: Apache Ant(TM)
version 1.10.7 compiled on September 1 2019 JVM: 14 (Oracle
Corporation 14+36-1461) OS: Windows 10 10.0 amd64
Type java --version to get the java version:
C:>java --version
java 14 2020-03-17 Java(TM) SE Runtime Environment
(build 14+36-1461) Java HotSpot(TM) 64-Bit Server VM (build
14+36-1461, mixed mode, sharing)
If you use Gradle wrapper you can use the following command to change the gradle wrapper to version 6.3:
gradle wrapper --gradle-version=6.3
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.
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.
I tried installing jenkins on Ubuntu 14.04.5 and ended up with some errors saying,
Setting up jenkins (2.80) ...
Found an incorrect Java version
Java version found:
java version "1.7.0_131"
OpenJDK Runtime Environment (IcedTea 2.6.9) (7u131-2.6.9-0ubuntu0.14.04.2)
OpenJDK 64-Bit Server VM (build 24.131-b00, mixed mode)
Aborting
invoke-rc.d: initscript jenkins, action "start" failed.
dpkg: error processing package jenkins (--configure):
subprocess installed post-installation script returned error exit status 1
Processing triggers for ureadahead (0.100.0-16) ...
Errors were encountered while processing:
jenkins
E: Sub-process /usr/bin/dpkg returned an error code (1)
As jenkins requires Java 8 to run, I tried installing Java 8 and again getting the same error mentioned above. I have tried removing jenkins, ended up with the same error "Found an incorrect Java version".
I need help to get this issue resolved. Thanks in advance.
Have a look here:
can't upgrade jenkins for java version error
If that does not help:
Have you checked alternatives and JAVA_HOME? If not, please check the output of these commands:
update-alternatives --config java
echo $JAVA_HOME
Both should be set to java 8 values.