How to build phonegap offline from command line - android

I'm using phonegap 100% from the command line. If I build while connected to the internet it works
$ phonegap build android
[phonegap] executing 'cordova build android'...
[phonegap] completed 'cordova build android'
But if I disconnect from the internet I get errors
$ phonegap build android
[phonegap] executing 'cordova build android'...
cp: no such file or directory: /Users/gregg/src/hft-mobile-app/icon.png
Running command: /Users/gregg/src/hft-mobile-app/platforms/android/cordova/build
ANDROID_HOME=/Users/gregg/Downloads/android-sdk-macosx
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
Running: /Users/gregg/src/hft-mobile-app/platforms/android/gradlew cdvBuildDebug -b /Users/gregg/src/hft-mobile-app/platforms/android/build.gradle -Dorg.gradle.daemon=true
FAILURE:
Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:1.0.0+.
Required by:
:android:unspecified
>
Failed to list versions for com.android.tools.build:gradle.
>
Unable to load Maven meta-data from https://repo1.maven.org/maven2/com/android/tools/build/gradle/maven-metadata.xml.
>
Could not GET 'https://repo1.maven.org/maven2/com/android/tools/build/gradle/maven-metadata.xml'.
>
repo1.maven.org: nodename nor servname provided, or not known
* 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: 30.753 secs
/Users/gregg/src/hft-mobile-app/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/gregg/src/hft-mobile-app/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/gregg/src/hft-mobile-app/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/gregg/src/hft-mobile-app/platforms/android/cordova/build: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: /Users/gregg/src/hft-mobile-app/platforms/android/cordova/build: Command failed with exit code 1
at ChildProcess.whenDone (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
Why is the command line version phoning home? How do I get this to build 100% offline?
Note: I see this error as the 2nd line when trying to build offline
cp: no such file or directory: /Users/gregg/src/hft-mobile-app/icon.png
But as you can see that error does not occur online. Plus supposedly whatever that issue was was fixed according to this
I'm on OSX, I've got the Android SDK installed. I had no idea it was calling home. How do I get it to build offline?

This is what I have experienced till now. Ionic uses gradle for android build. It first time downloads all the dependencies from internet. So internet is most for first gradle build but it caches them and no internet is needed for further build.Since you are having problem why don't you globally update your cordova and ionic.
npm install -g cordova ionic

Related

"ionic cordova build" fails to build apk

I cannot build an apk in cordova. Build always fails.
Set my android SDK home
export ANDROID_HOME/home/felipe/Android/Sdk/
First, build cannot find gradle, so i put gradle in path. I have tried this with downloaded gradle or the gradle that i have in android studio.
export PATH=$PATH:/home/felipe/gradle-4.1/bin
For make sure that i have updated versions of cordova and ionic
npm install -g cordova#latest
npm install -g ionic#latest
simple sample app
ionic start sidemenu sidemenu --type ionic1
cd sidemenu
ionic cordova platform add android
ionic cordova build android
And then i got:
> ionic cordova prepare
> cordova prepare
✔ Running command - done!
Running command: /home/felipe/ionic-testes/sidemenu/hooks/after_prepare/010_add_platform_class.js /home/felipe/ionic-testes/sidemenu
add to body class: platform-android
> cordova build android
✖ Running command - failed!
[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.
[ERROR] An error occurred while running cordova build android (exit code 1):
Running command: /home/felipe/ionic-testes/sidemenu/hooks/after_prepare/010_add_platform_class.js
/home/felipe/ionic-testes/sidemenu
add to body class: platform-android
ANDROID_HOME=/home/felipe/Android/Sdk/
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
Subproject Path: CordovaLib
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:2.2.3.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:2.2.3.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom'.
> Could not HEAD 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested
target
* 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: 2.176 secs
Error: /home/felipe/ionic-testes/sidemenu/platforms/android/gradlew: Command failed with exit code 1 Error
output:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:2.2.3.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:2.2.3.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom'.
> Could not HEAD 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested
target
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Please. Could somebody help me? Thank you for attention
Solved. I've Just opened in Android Studio.
I don't know why, but the user whose answar was correct has deleted his post. I had installed sdk with sdk manager in Android Studio, and i had installed other updates suggested by Android Studio, but only when i open the project in android studio it did the updates required.
From error message, i guess i have some Certification Authority missing in my open jdk installation (i am using openjdk from ubuntu repositories and have installed ca-certificates-java package). But, for now, it works.
Please create project with this commands
Ionic start sidemenu sidemenu --blank
Cd sidemenu
Add required platform Android, iOS
4.Cordova build android
Cordova run android

Gradle error while trying to build android application using Cordova

I use cordova to build android apps:
$ cordova build android
I got an error:
Error: 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
Then I tried install gradle:
$ sudo apt install gradle
And then I'm struggling with this one:
aqil#dell:~/hello$ cordova build
ANDROID_HOME=/home/aqil/Android/Sdk
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
/usr/lib/jvm/java-8-openjdk-amd64/bin/java: symbol lookup error: /usr/lib/jni/libnative-platform-curses.so: undefined symbol: tgetent
Error: /usr/share/gradle/bin/gradle: Command failed with exit code 127
This worked for me:
Remove Gradle sudo apt-get remove gradle
Add this to your .bashrc file: export PATH=${PATH}:/opt/android-studio/gradle/gradle-X.XX.X/bin (Where X.XX.X is the version under this path.)
Now cordova build android should work without errors.
I finally could solve the issue. It was something wrong with the gradle. First step: removing it.
$ sudo apt remove gradle
Then i downloaded it manually from the link below
gradle-3.5.zip
Extract then add it's path into the environment using the command below:
$ sudo gedit ~/.bashrc
Add these two path at the bottom of the file:
export GRADLE_HOME=/home/aqil/Android/gradle-3.5
export PATH=$PATH:$GRADLE_HOME/bin
Final step, Tried building but encountered an error:
BUILD FAILED
Total time: 9 mins 33.837 secs Error: /home/aqil/App/platforms/android/gradlew: Command failed with exit code 1 Error output: FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring root project 'android'. Could not resolve all dependencies for configuration ':_debugApk'. A problem occurred configuring project ':CordovaLib'. Could not resolve all dependencies for configuration ':CordovaLib:classpath'. Could not resolve com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3. Required by: project :CordovaLib Could not resolve com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3. Could not get resource 'https://jcenter.bintray.com/com/jfrog/bintray/gradle/gradle-bintray-plugin/1.7.3/gradle-bintray-plugin-1.7.3.pom'. Could not GET 'https://jcenter.bintray.com/com/jfrog/bintray/gradle/gradle-bintray-plugin/1.7.3/gradle-bintray-plugin-1.7.3.pom'. Connect to jcenter.bintray.com:443 [jcenter.bintray.com/108.168.243.150] failed: Connection timed out (Connection timed out)
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
this is network problem. Proxy helped me to bypass network filtering.

How to make Android Cordova project built with Gradle build offline?

I have a Ionic/Cordova project, builds for Android are done with Gradle.
I installed all necessary Android SDKs and the project was building fine for many months, but today it fails with the following error:
Running: d:\git\myproject\platforms\android\gradlew cdvBuildDebug -b d:\git\myproject\platforms\android\build.gradle -Dorg.gradle.daemon=true
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:1.0.0+.
Required by:
BUILD FAILED
Total time: 26.792 secs
:android:unspecified
> Failed to list versions for com.android.tools.build:gradle.
> Unable to load Maven meta-data from https://repo1.maven.org/maven2/com/android/tools/build/gradle/maven-metadata.xml.
> Could not GET 'https://repo1.maven.org/maven2/com/android/tools/build/gradle/maven-metadata.xml'.
> Connection to https://repo1.maven.org refused
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
d:\git\myproject\platforms\android\cordova\node_modules\q\q.js:126
throw e;
^
Error code 1 for command: cmd with args: /s /c "d:\git\myproject\platforms\android\gradlew cdvBuildDebug -b d:\git\myproject\platforms\android\build.gradle -Dorg.gradle.daemon=true"
Error: cmd: Command failed with exit code 1
Cordova command failed with error code 1, aborting!
Clearly, since the project was building just fine for months, everything needed to have it build is already on disk, but the build is probably checking if there are updated version of artifacts in the Maven repo, and this is failing.
This is not a very desired behavior sometimes.
Is it possible to configure the build to always build offline?
So I grepped my repo for com.android.tools.build:gradle and I found it in a few files:
D:\git\myproject\platforms\android\build.gradle\build.gradle
D:\git\myproject\platforms\android\cordova\lib\plugin-build.gradle\plugin-build.gradle
D:\git\myproject\platforms\android\CordovaLib\build.gradle\build.gradle
I changed
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0+'
}
to
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
Hopefully this solves my issue, although the problem is gone now even with 1.0.0+, so I can't really verify that easily.
You can check which exact version of com.android.tools.build:gradle you have available locally in the following folder when on Windows:
$HOME\.gradle\caches\modules-2\files-2.1\com.android.tools.build\gradle

Apache Cordova Execution failed for task ':compileDebugJavaWithJavac'

After some updates to Android Studio and Apache Cordova my Apache Cordova project is not building.
I am new to Apache Cordova, OS X and Android Studio.
In Android Studio when I Rebuild Project I get the following error in the Gradle console.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':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.
BUILD FAILED
In the terminal when I run the command cordova --version it prints out 4.0.0 and which javac prints out /usr/bin/javac but echo $JAVA_HOME prints nothing (an empty line).
UPDATE: I am setting the path of JAVA_HOME and ANDROID_HOME in the terminal even though I get the same errors as shown below and after closing the terminal the JAVA_HOME and ANDROID_HOME environment variables are lost, I set them as export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home and export ANDROID_HOME=/Users/apple/Library/Android/sdk
When I try to build the project from Cordova CLI also it is not working.
I get the following errors, where as if I create a new project after changing the distributionUrl in gradle-wrapper.properties and changing the buildToolsVersion from "19.0.0" to "19.1.0" the new project worked fine.
Please help.
cordova compile command
Sreekanth-2:19:02:16 Sreekanth$ cordova compile
Running command: "/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/cordova/build"
Buildfile: /Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/build.xml
BUILD FAILED
/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/build.xml:7: The following error occurred while executing this line:
java.io.FileNotFoundException: /Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:/usr/local/Cellar/ant/1.9.7/libexec/lib/ant.jar (No such file or directory)
at java.io.RandomAccessFile.open0(Native Method)
at java.io.RandomAccessFile.open(RandomAccessFile.java:316)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:243)
at org.apache.tools.zip.ZipFile.<init>(ZipFile.java:212)
at org.apache.tools.zip.ZipFile.<init>(ZipFile.java:177)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:256)
at org.apache.tools.ant.helper.ProjectHelper2.parseUnknownElement(ProjectHelper2.java:131)
at org.apache.tools.ant.helper.ProjectHelper2.parseAntlibDescriptor(ProjectHelper2.java:111)
at org.apache.tools.ant.taskdefs.Antlib.createAntlib(Antlib.java:94)
at org.apache.tools.ant.taskdefs.Definer.loadAntlib(Definer.java:425)
at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:277)
at org.apache.tools.ant.ComponentHelper.checkNamespace(ComponentHelper.java:874)
at org.apache.tools.ant.ComponentHelper.getDefinition(ComponentHelper.java:307)
at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:284)
at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:263)
at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:430)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:164)
at org.apache.tools.ant.Task.perform(Task.java:347)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:180)
at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:93)
at org.apache.tools.ant.Main.runBuild(Main.java:829)
at org.apache.tools.ant.Main.startAnt(Main.java:236)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
Total time: 0 seconds
/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: ant with args: debug,-f,/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: /Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/cordova/build: Command failed with exit code 1
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
cordova build command
Sreekanth-2:19:02:16 Sreekanth$ cordova build
Running command: "/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/cordova/build"
Buildfile: /Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/build.xml
BUILD FAILED
/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/build.xml:7: The following error occurred while executing this line:
java.io.FileNotFoundException: /Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:/usr/local/Cellar/ant/1.9.7/libexec/lib/ant.jar (No such file or directory)
at java.io.RandomAccessFile.open0(Native Method)
at java.io.RandomAccessFile.open(RandomAccessFile.java:316)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:243)
at org.apache.tools.zip.ZipFile.<init>(ZipFile.java:212)
at org.apache.tools.zip.ZipFile.<init>(ZipFile.java:177)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:256)
at org.apache.tools.ant.helper.ProjectHelper2.parseUnknownElement(ProjectHelper2.java:131)
at org.apache.tools.ant.helper.ProjectHelper2.parseAntlibDescriptor(ProjectHelper2.java:111)
at org.apache.tools.ant.taskdefs.Antlib.createAntlib(Antlib.java:94)
at org.apache.tools.ant.taskdefs.Definer.loadAntlib(Definer.java:425)
at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:277)
at org.apache.tools.ant.ComponentHelper.checkNamespace(ComponentHelper.java:874)
at org.apache.tools.ant.ComponentHelper.getDefinition(ComponentHelper.java:307)
at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:284)
at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:263)
at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:430)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:164)
at org.apache.tools.ant.Task.perform(Task.java:347)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:180)
at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:93)
at org.apache.tools.ant.Main.runBuild(Main.java:829)
at org.apache.tools.ant.Main.startAnt(Main.java:236)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
Total time: 0 seconds
/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: ant with args: debug,-f,/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: /Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/cordova/build: Command failed with exit code 1
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
Sreekanth-2:19:02:16 Sreekanth$
Go to Project.Properties
add the following lines
cordova.system.library.1=com.google.android.gms:play-services-auth:9.8.0
cordova.system.library.2=com.google.android.gms:play-services-identity:9.8.0
run the cordova commands again, You can able to build a release and debug builds
Type the following in your terminal
echo "export JAVA_HOME=/usr/libexec/java_home"
This will print the exact export for Java_home , copy that and paste it in terminal and press enter.
Then try echo $java_home.

Cordova Android Build Failure

I am trying to get the basic Cordova v5.0 Android v4.0 project to build on Mac OS X Yosemite, but keep getting this error. Note: The same process builds fine on Cordova v4. I have uninstalled and reinstalled the Android SDK, Cordova, and even Gradle (but I don't think I need it). I've checked that my Path variable contains the correct paths to /tools and /platform_tools. But when I do the 'cordova build' or 'cordova build android' I always get the same error:
Could not create an instance of type
org.gradle.invocation.DefaultGradle_Decorated.
Further down it says:
You may not have the required environment or OS to build this project
What am I missing?
Here's the full text of what I'm doing:
my_acct$cordova create build_test com.example.build_test "BuildTest"
Creating a new cordova project.
my_acct$cd build_test
my_acct$cordova platform add android
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms/android
Package: com.example.build_test
Name: BuildTest
Activity: MainActivity
Android target: android-22
Copying template files...
Android project created with cordova-android#4.0.0
Discovered plugin "cordova-plugin-whitelist" in config.xml. Installing to the project
Fetching plugin "cordova-plugin-whitelist#1" via npm
npm http GET https://registry.npmjs.org/cordova-plugin-whitelist
npm http GET https://registry.npmjs.org/cordova-plugin-whitelist
npm http 304 https://registry.npmjs.org/cordova-plugin-whitelist
Installing "cordova-plugin-whitelist" for android
my_acct$cordova build
Running command: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build
ANDROID_HOME=/Users/my_acct/Documents/Development/android-sdk-macosx/sdk
JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Running: /Users/my_acct/Documents/Development/work/build_test/platforms/android/gradlew cdvBuildDebug -b /Users/my_acct/Documents/Development/work/build_test/platforms/android/build.gradle -Dorg.gradle.daemon=true
FAILURE: Build failed with an exception.
* What went wrong:
Could not create an instance of type org.gradle.invocation.DefaultGradle_Decorated.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
/Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/my_acct/Documents/Development/work/build_test/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/my_acct/Documents/Development/work/build_test/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build: Command failed with exit code 8
at ChildProcess.whenDone (/Users/my_acct/.node/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:766:16)
at Process.ChildProcess._handle.onexit (child_process.js:833:5)
If I change to use java 1.7 or 1.8, the error changes to:
A problem occurred configuring root project 'android'.
Could not resolve all dependencies for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:1.0.0+.
Required by:
:android:unspecified
org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
Here's the full results for using java 1.7 or 1.8:
my_acct$cordova build
Running command: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build
ANDROID_HOME=/Users/my_acct/Documents/Development/android-sdk-macosx/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
Running: /Users/my_acct/Documents/Development/work/build_test/platforms/android/gradlew cdvBuildDebug -b /Users/my_acct/Documents/Development/work/build_test/platforms/android/build.gradle -Dorg.gradle.daemon=true
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:1.0.0+.
Required by:
:android:unspecified
> org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
* 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: 4.859 secs
/Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/my_acct/Documents/Development/work/build_test/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/my_acct/Documents/Development/work/build_test/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build: Command failed with exit code 8
at ChildProcess.whenDone (/Users/my_acct/.node/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:766:16)
at Process.ChildProcess._handle.onexit (child_process.js:833:5)
I figured it out. I found old, conflicting .jar files in ~/Library/Java/Extensions. Blew away the entire ~/Library/Java directory. Cordova (and Android Studio) runs great now.
The other way how this problem can be resolved is by changing the repository from
mavenCentral()
to
maven{
url 'https://repo1.maven.org/maven2'
}
in both platforms/android/build.gradle and platforms/android/CordovaLib/build.gradle

Categories

Resources