Nativescript Android build fails suddenly (NS6) - nativescript

My Nativescript 6 Android build suddenly is failing - I didn't update any modules except for the NS CLI 8.2.3 - but the tns-android is 6.5.x
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/mini/Projects/app-mobile/platforms/tempPlugin/nativescript_webview_ext/build.gradle' line: 6
* What went wrong:
A problem occurred evaluating root project 'nativescript_webview_ext'.
> Failed to apply plugin 'com.android.internal.library'.
> Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing `org.gradle.java.home` in `gradle.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 684ms
Failed to build plugin #nota/nativescript-webview-ext :
Error: Command ./gradlew failed with exit code 1
Again this was working before the CLI update.
I'm using Java 1.8 - seems to be a big jump to Java 11.

Failed to apply plugin 'com.android.internal.library'.
Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing `org.gradle.java.home` in `gradle.properties`.
As it can be read from the error message, gradle is expecting jdk 11 and you have jdk 8 configured. Install jdk 11 on the system and set JAVA_HOME environment variable to point to it.
This is probably happening because nativescript 8.2.3 seems to be using gradle 7 and it expects jdk 11. You can specify gradle version in a somewhat hacky way likewise:
How can I downgrade the Gradle in NativeScript?

Related

Build failed with an exception Could not resolve io.github.g00fy2:versioncompare:1.5.0

cordova.cmd build android --release
The "" tags were detected and are no longer supported. Please migrate to the "preference" tag "AndroidWindowSplashScreenAnimatedIcon".
cordova-plugin-androidx-adapter: Processed 34 source files in 588ms
Checking Java JDK and Android SDK versions
ANDROID_HOME=C:\Users\iamsh\AppData\Local\Android\Sdk (recommended setting)
ANDROID_SDK_ROOT=C:\android-sdk-windows (DEPRECATED)
Using Android SDK: C:\android-sdk-windows
Subproject Path: CordovaLib
Subproject Path: app
FAILURE: Build failed with an exception.
Where:
Build file 'C:\Webtrikon\quickchicken\platforms\android\build.gradle' line: 21
What went wrong:
A problem occurred evaluating root project 'Quick Chicken'.
Could not resolve all files for configuration 'classpath'.
Could not resolve io.github.g00fy2:versioncompare:1.5.0.
Required by:
unspecified:unspecified:unspecified
> Could not resolve io.github.g00fy2:versioncompare:1.5.0.
> Could not get resource 'https://repo.maven.apache.org/maven2/io/github/g00fy2/versioncompare/1.5.0/versioncompare-1.5.0.pom'.
> Could not GET 'https://repo.maven.apache.org/maven2/io/github/g00fy2/versioncompare/1.5.0/versioncompare-1.5.0.pom'.
> The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/7.4.2/userguide/build_environment.html#gradle_system_properties
> Remote host terminated the handshake
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 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.4.2/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 3s
Command failed with exit code 1: C:\Webtrikon\quickchicken\platforms\android\gradlew :app:bundleRelease -b C:\Webtrikon\quickchicken\platforms\android\build.gradle
[ERROR] An error occurred while running subprocess cordova.
cordova.cmd build android --release exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
how to solve this error, Stuck with it from past 4 days.

Build the project using gradle

I have so far used maven to build the java code.
I was trying to build this project which is using gradle: https://github.com/opendistro-for-elasticsearch/anomaly-detection
I followed the below steps and it is failing continuously in build.
After cloning the code,
Step 1: As per the steps mentioned in the link, I installed java first and set the Java home and path like below
yum install java-1.8.0-openjdk
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
export PATH=$JAVA_HOME/bin:$PATH
Step 2 : I tried to build the project using gradlew like below and end up with the error,
anomaly-detection]# ./gradlew
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
FAILURE: Build failed with an exception.
* Where:
Build file '/host/eclipse_back/opendistro/anomaly-detection/build.gradle' line: 55
* What went wrong:
A problem occurred evaluating root project 'opendistro-anomaly-detection'.
> Failed to apply plugin [id 'elasticsearch.esplugin']
> Could not create plugin of type 'PluginBuildPlugin'.
> Could not generate a decorated class for type PluginBuildPlugin.
> org/elasticsearch/gradle/plugin/PluginPropertiesExtension has been compiled by a more recent version of the Java Runtime (class file version 54.0), this version of the Java Runtime only recognizes class file versions up to 52.0
* 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 8s
Why it's failing? Any help is appreciated!
Thanks,
Harry
You need to setup your build environment for gradle to use a more recent java version. You can set the java version with the gradle property org.gradle.java.home:
org.gradle.java.home=<path to JDK home>
I think the problem is that you use Java 8 and in the README they want to use Java 14.
To build from command line set JAVA_HOME to point to a JDK 14 before running ./gradlew
Then it should be possible to build and test the project with the following command:
./gradlew build
EDIT:
Can you check your configuration of your IDE. Did the Gradle JVM use the correct Java version? If you are using Intellik you can check it following this post:

Minecraft Forge Gradle with VSCode

I am trying to create a Minecraft Mod using VSCode as this is my main editor for school, but when I try to run the command gradlew genVSCodeRun I get the follwoing output that says successful, but also "Could not resolve: net.minecraftforge:forge:1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3". When I then run gradlew build, the following it output:
Task :compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
Could not find net.minecraftforge:forge:1.15.2-31.1.0_mapped_snapshot_20200119-1.14.3.
Searched in the following locations:
- file:/C:/Users/eabla/.gradle/caches/forge_gradle/bundeled_repo/net/minecraftforge/forge/1.15.2-31.1.0_mapped_snapshot_20200119-1.15/forge-1.15.2-31.1.0_mapped_snapshot_20200119-1.14.3.pom
- file:/C:/Users/eabla/.gradle/caches/forge_gradle/bundeled_repo/net/minecraftforge/forge/1.15.2-31.1.0_mapped_snapshot_20200119-1.15/forge-1.15.2-31.1.0_mapped_snapshot_20200119-1.14.3.jar
- https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3/forge-1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3.pom
- https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3/forge-1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3.jar
- https://libraries.minecraft.net/net/minecraftforge/forge/1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3/forge-1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3.jar
- https://repo.maven.apache.org/maven2/net/minecraftforge/forge/1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3/forge-1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3.pom
- https://repo.maven.apache.org/maven2/net/minecraftforge/forge/1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3/forge-1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3.jar
Required by:
project :
* 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 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:command_line_warnings
BUILD FAILED in 40s
1 actionable task: 1 executed
Any idea what this could be? I have done a fresh install of java JDK and JRE as well as a fresh install of the Forge MDK.
Your Forge Library is missing. Run the command gradlew eclipse after navigating into your project directory. It may take some time but it will surely fix it. :D
Make sure you have the JDK (java development kit https://www.oracle.com/java/technologies/javase-jdk8-downloads.html) installed not just the JRE

Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $ on generate APK

My project is run on AVD properly. but when i try to generate signed APK, gradle get this error:
FAILURE: Build failed with an exception.
* What went wrong:
java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $
> Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $
* 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
I've used this command many times: gson.fromJson. but i can't find error source. (which file and which line).
So how do I find the source of the error
I got this problem in Android Studio 4.0 when I did a Gradle sync. I fixed it by doing the following:
Open top-level build.gradle and change the gradle classpath to:
classpath 'com.android.tools.build:gradle:4.0.0'
Open gradle\wrapper\gradle-wrapper.properties and change the distribution URL to:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
Copy in .idea\jarRepositories.xml from a new project
No idea how or why, but it worked for me
I got this error in Android Studio 4.0 when I did a Gradle sync after switching branches. I fixed it by doing this:
Build -> Clean Project
Sync Project with Gradle files
I had the same problem when I tried to build a "signed release APK". I was using Android Studio Beta 4.0.
To fix the problem, I've upgraded to Beta 4.0 v4 and it resolved the problem.
i changed the place where my APKs generated inside and it's working fine now

Android studio build error

Tried to create my first project in android studio, using one of the examples im trying to run the application, but gradle gives me this build error (didnt change one line of code - just trying to run the Empty activity):
Gradle: FAILURE: Build failed with an exception.
* What went wrong: Execution failed for task ':Passivelocation:packageDebug'.
org.bouncycastle.asn1.ASN1Integer.(J)V
* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Ive tried adding info and debug while running the command on with the cli but i cant make much of the output it gives me.
Any suggestions?
I faced the same failure and the problem was with my jdk/jre because some time ago I added the Bouncy Castle Crypto APIs functionality by adding the jar to my jdk/jre path.
I tried a gradle build with a "clean" jdk/jre and problem was solved

Resources