Cordova Platform Add Error Android - java

I'm using cordova 6.4.0 with node 6.9.4. I have android studio installed in my PC (windows) with SDK 23,24,25 and ANDROID_HOME, ANDROID_NDK_HOME, ANT_HOME, JAVA_HOME in my system variable. After creating a new project using cordova and then trying to add android platform I'm getting following error:
E:\Android\q>cordova platform add android
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms\android
Package: io.cordova.hellocordova
Name: HelloCordova
Activity: MainActivity
Android target: android-24
Subproject Path: CordovaLib
Android project created with cordova-android#6.0.0
Installing "cordova-plugin-whitelist" for android
ANDROID_HOME=C:\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_121
Subproject Path: CordovaLib
Incremental java compilation is an incubating feature.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> java.lang.NullPointerException (no error message)
* 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: 8.891 secs
Failed to install 'cordova-plugin-whitelist':Error: cmd: Command failed with exit code 1
at ChildProcess.whenDone (E:\Android\q\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
Error: cmd: Command failed with exit code 1
I uninstalled JAVA(JDK,JRE), Andorid Studio, Cordova CLI and reinstalled them. After that I'm getting same error. I tried removing whitelist plugin and it throw build error with exit code 1. How to solve this ?

Related

How to solve Could not determine the dependencies of task ':app:compileDebugJavaWithJavac' - Android

I am trying to run Android project in an AVD Manager. When the program compiles it throws an exception.
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Installed Build Tools revision 32.0.0 is corrupted. Remove and install again using the SDK Manager.
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.internal.tasks.TaskDependencyResolveException: Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
at org.gradle.api.internal.tasks.CachingTaskDependencyResolveContext.getDependencies(CachingTaskDependencyResolveContext.java:69)
at org.gradle.execution.plan.TaskDependencyResolver.resolveDependenciesFor(TaskDependencyResolver.java:46)
at org.gradle.execution.plan.LocalTaskNode.getDependencies(LocalTaskNode.java:160)
at org.gradle.execution.plan.LocalTaskNode.resolveDependencies(LocalTaskNode.java:128)
at org.gradle.execution.plan.DefaultExecutionPlan.doAddNodes(DefaultExecutionPlan.java:163)
at org.gradle.execution.plan.DefaultExecutionPlan.addEntryTasks(DefaultExecutionPlan.java:133)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph.addEntryTasks(DefaultTaskExecutionGraph.java:147)
at org.gradle.execution.TaskNameResolvingBuildConfigurationAction.configure(TaskNameResolvingBuildConfigurationAction.java:49)
at org.gradle.execution.DefaultBuildConfigurationActionExecuter.configure(DefaultBuildConfigurationActionExecuter.java:55)
at org.gradle.execution.DefaultBuildConfigurationActionExecuter.access$000(DefaultBuildConfigurationActionExecuter.java:26)
at org.gradle.execution.DefaultBuildConfigurationActionExecuter$1.proceed(DefaultBuildConfigurationActionExecuter.java:63)
at org.gradle.execution.DefaultTasksBuildExecutionAction.configure(DefaultTasksBuildExecutionAction.java:45)
at org.gradle.execution.DefaultBuildConfigurationActionExecuter.configure(DefaultBuildConfigurationActionExecuter.java:55)....
Caused by: java.lang.IllegalStateException: Installed Build Tools revision 32.0.0 is corrupted. Remove and install again using the SDK Manager.
at com.android.builder.sdk.DefaultSdkLoader.getTargetInfo(DefaultSdkLoader.java:183)
at com.android.build.gradle.internal.SdkHandler.initTarget(SdkHandler.java:113)
... 137 more
I have tried several solutions for a workaround. I have tried to change CompledSDK, TargetSDK and BuildTools to 31, 30 and 29 but none of them worked for me.
Any help!
Try to execute the following command inside your project directory:
./gradlew clean
and re-run it in the studio.

Could not resolve all files for configuration ':app:androidJdkImage

I am trying to build flutter apk on debug mode from android studio.
Flutter run
I get this error:
Launching lib/main.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
Could not resolve all files for configuration ':app:androidJdkImage'.
Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for JdkImageTransform: /Users/mac/Library/Android/sdk/platforms/android-30/core-for-system-modules.jar.
> jlink executable /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/jlink does not exist.
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 20s
Exception: Gradle task assembleDebug failed with exit code 1
I solved this issue by downloading the required NDK side by side
package as shown in this screenshot for the required SDK platform.
If you keep getting errors after doing this, please share error logs or screenshots. Thanks.
In my case, I only need update Android Studio to newer version and it's working normally again.

Cordova build failed not sure why it is happening

All of my version are i think right but the build always fail please help me
i am sure that the java is perfect but not to sure about the android sdk
My gradle version Gradle 6.4
My adb version Android Debug Bridge version 1.0.41
Version 31.0.3-7562133
C:\Cordova\Hello>cordova build android
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=G:\Android sdk (cordova)\platform-tools_r31.0.3-windows\platform-tools (recommended setting)
ANDROID_HOME=C:\Android (DEPRECATED)
Using Android SDK: G:\Android sdk (cordova)\platform-tools_r31.0.3-windows\platform-tools
Subproject Path: CordovaLib
Subproject Path: app
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Script 'C:\Cordova\Hello\platforms\android\CordovaLib\cordova.gradle' line: 64
* What went wrong:
A problem occurred evaluating project ':app'.
> No installed build tools found. Install the Android build tools version 19.1.0 or higher.
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> compileSdkVersion is not specified. Please add it to build.gradle
* 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
Command failed with exit code 1: C:\Cordova\Hello\platforms\android\gradlew cdvBuildDebug -b C:\Cordova\Hello\platforms\android\build.gradle
This needs to be fixed in Android Studio. Open the SDK Manager, then go to the "SDK tools" tab and check "show package details". " Android SDK build tools " will be there. Check the box next to the Android SDK build tools 19.1.0 (or whatever number your error code is referencing) and hit 'Apply' to install.

ionic cordova build android error nuillpoijtexception

When I run cordova build android I had error.
exit /b 1 Command finished with error code 1:\platforms\android\gradlew cdvBuildDebug,-b,myprodplatforms\android\build.gradle myprodplatforms\android\gradlew: Command failed with exit code 1 Error output: Exception in thread "main" java.lang.NullPointerException
at org.gradle.wrapper.PathAssembler.getDistName(PathAssembler.java:84)
at
org.gradle.wrapper.PathAssembler.getDistribution(PathAssembler.java:40)
at org.gradle.wrapper.Install.createDist(Install.java:44)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:63) Error: myprodplatforms\android\gradlew: Command failed with exit code 1 Error output: Exception in thread "main" java.lang.NullPointerException
at org.gradle.wrapper.PathAssembler.getDistName(PathAssembler.java:84)
at org.gradle.wrapper.PathAssembler.getDistribution(PathAssembler.java:40)
at org.gradle.wrapper.Install.createDist(Install.java:44)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:63)
at ChildProcess.whenDone (myprodnode_modules\cordova-common\src\superspawn.js:135:23)
at ChildProcess.emit (events.js:210:5)
at ChildProcess.cp.emit (myprodnode_modules\cross-spawn\lib\enoent.js:34:29)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5) [ERROR] An error occurred while running subprocess cordova.
cordova.cmd build android --verbose exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
I tried to remove and add android remove node modules, I updated node module to latest version .
Can someone give me idea how to solved error.
Ivan, One thing seems typo, the command is ionic cordova build android, you have mentioned only cordova build android command, ionic is missing.
It seems your error is more related to Android Studio/Gradle installation not related to node module or ionic. still as per error mentioned which itself suggests please run build command with --verbose flag as below.
ionic cordova build android --verbose
the --verbose flag may help you to give exact Gradle or specific component associated error, which can further help you to reach to the specific root cause.
Please run ionic cordova build android instead of cordova build android to get APK and run ionic cordova build ios to get IPA

npm run android in react native giving build error

After running react-native run-android:
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'pusher'.
Could not resolve all dependencies for configuration ':classpath'.
Could not download protobuf-java.jar (com.google.protobuf:protobuf-java:2.5.0)
Could not get resource 'https://jcenter.bintray.com/com/google/protobuf/protobuf-java/2.5.0/protobuf-java-2.5.0.jar'.
Could not GET 'https://jcenter.bintray.com/com/google/protobuf/protobuf-java/2.5.0/protobuf-java-2.5.0.jar'.
sun.security.validator.ValidatorException: No trusted certificate found
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
I have installed SDK tools,have followed react native documentation properly,but still have hit a snag.
I am using Ubuntu 16.
Go to your build.gradle file in [your project name]\android\app and under "dependencies", change the 'com.android.support:appcompat-v7:23.0.1' dependency to 23.0.0.

Categories

Resources