0

I'm new to Cordova, I can run my code in the browser using cordova run browser but I would like to turn it into an apk so I can run it on my phone and really test it.

The developer I am working with sends me apk all the time built from the same files whenever he has an update on the project, however when I want to make minor changes myself I can't create an apk to test them because it throws an error.

cordova build android --release

Error: Error code 1 for command: cmd with args: /s,/c,"X:\Websites\AppAndroid\platforms\android\gradlew cdvBuildDebug -b X:\Websites\AppAndroid\platforms\android\build.gradle -Dorg.gradle.daemon=true -Pandroid.useDeprecatedNdk=true"

It also says this but I can't make sense of it with my limited knowledge

FAILURE: Build failed with an exception. What went wrong: Execution failed for task ':transformClassesWithDexForDebug'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1

I have tried some other solutions from other questions and YouTube videos such as setting my paths to JAVA and ANDROID_HOME but these didn't help my issue.

The read out also makes a suggestion, I tried this but it doesn't tell me anything extra in a log or fix the issue:

Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

UPDATE

I am wondering if it is my JAVA_HOME path.

That is set to 1.7.0_79

ANDROID_HOME=C:\User\Me\AppData\Local\Android\sdk JAVA_HOME=C:\Program Files\java\jdk1.7.0_79

But when I do java -version I get this 1.8.0_121:

java version "1.8.0_121" Java(TM) SE Runtime Environment (build 1.8.0_121-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

That's 2 different versions, but when I change JAVA_HOME in the environments window, it doesn't change JAVA_HOME that is displayed when I try to build the apk.

So I am unable to correct it to see if it fixes the error :\

GoldenGonaz
  • 1,116
  • 2
  • 17
  • 42

1 Answers1

0

I had configured JAVA_HOME wrong in my Environment Variables settings.

It was out of date compared to the Java I had installed.

Then when I tried to change it, I realised I didn't have the JDK installed, I only had JRE (Java Runtime Environment).

So I Googled javascript development kit download and was taken to the website and downloaded the JDK, then correctly set my paths in the Environment Variables settings to represent JDK not JRE.

I closed console and ran it all again and success, built!

GoldenGonaz
  • 1,116
  • 2
  • 17
  • 42