Cordova fails to build project
Asked Answered
F

3

4

Update: new readers, check my last edit please.

After updating cordova, it fails to buld/run

Mac-mini-de-Toni:funcook toniweb$ sudo cordova build
Password:
Running command: /Users/toniweb/Proyectos/cordova/funcook/platforms/android/cordova/build 
ANDROID_HOME=/usr/local/Cellar/android-sdk/22.6.2
JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Running: /Users/toniweb/Proyectos/cordova/funcook/platforms/android/gradlew cdvBuildDebug -b /Users/toniweb/Proyectos/cordova/funcook/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 ':_debugCompile'.
   > Could not find any version that matches com.android.support:support-v4:+.
     Searched in the following locations:
         https://repo1.maven.org/maven2/com/android/support/support-v4/maven-metadata.xml
         https://repo1.maven.org/maven2/com/android/support/support-v4/
     Required by:
         :android:unspecified

* 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: 9.374 secs

/Users/toniweb/Proyectos/cordova/funcook/platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                          ^
Error code 1 for command: /Users/toniweb/Proyectos/cordova/funcook/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/toniweb/Proyectos/cordova/funcook/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/toniweb/Proyectos/cordova/funcook/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/toniweb/Proyectos/cordova/funcook/platforms/android/cordova/build: Command failed with exit code 8
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:139:23)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:753:16)
    at Process.ChildProcess._handle.onexit (child_process.js:820:5)

I checked that I have the target 22 installed which is set in the project.properties

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-22
android.library.reference.1=CordovaLib
cordova.system.library.1=com.android.support:support-v4:+

Any idea what I missing? (this was working fine before updating cordova)

-UPDATE-

Plugins:

Mac-mini-de-Toni:funcook toniweb$ cordova plugins list
org.apache.cordova.camera 0.3.6 "Camera"
org.apache.cordova.device 0.3.0 "Device"
org.apache.cordova.file 1.3.3 "File"
org.apache.cordova.inappbrowser 0.6.0 "InAppBrowser"
org.apache.cordova.media 0.2.16 "Media"
org.apache.cordova.media-capture 0.3.6 "Capture"

cordova platform update android:

Mac-mini-de-Toni:funcook toniweb$ cordova platform update android
Updating android project...
cp: copyFileSync: could not write to dest file (code=EACCES):/Users/toniweb/Proyectos/cordova/funcook/platforms/android/assets/www/cordova.js

ls: no such file or directory: /Users/toniweb/Proyectos/cordova/funcook/platforms/android/libs/cordova-*.jar

Android project updated with [email protected]

Versions:

Mac-mini-de-Toni:funcook toniweb$ npm version
{ http_parser: '1.0',
  node: '0.10.28',
  v8: '3.14.5.9',
  ares: '1.9.0-DEV',
  uv: '0.10.27',
  zlib: '1.2.3',
  modules: '11',
  openssl: '1.0.1g',
  npm: '1.4.9' }




Mac-mini-de-Toni:funcook toniweb$ node --version
v0.10.28



Mac-mini-de-Toni:funcook toniweb$ cordova -v
5.3.3

And this:

android list sdk

will prompt me to the java's download page, Which I installed and then rebooted, and still prompt me the same

No Java runtime present, requesting install. No Java runtime present, requesting install.

-EDIT-

By installing a jdk this last thing doesn't happen anymore

-EDIT-

By installing a jdk I can build and run cordova android only if I use sudo otherwise looks like same error

Forwhy answered 17/10, 2015 at 8:36 Comment(10)
A couple comments: (1) you shouldn't need to use sudo to run cordova build; and (2) have you tried a cordova platform rm android and cordova platform add android?Nobie
Also thinking out loud... what version did you upgrade from? A while back the cordova CLI moved from ant to gradle. I'm not sure if that's something that might have thrown your build off.Nobie
Which cordova plugins do you use in your app?Mcchesney
I will post the list later on, i'm not at home, but more or less: media, file, inapbrowser and that's it i thing, i will let you know for sure later onForwhy
npm version? node version? cordova cli version? cordova android version?Microbalance
Also refer to tynn's answer here: https://mcmap.net/q/1706985/-build-error-ionic-android-build-failed-with-an-exceptionNobie
have you update the project after upgrading cordova? run in the the project root: cordova platform update android/iosRattlehead
Question updated with your requests, I didn't try to remove/add the platform, shall I? (edit: I did, and didn't help..)Forwhy
Can you check whether Android Support Repository is installed in Android SDK Manager? You can also try to run cordova requirements to check if there are any missing dependencies.Yevetteyew
Requirements check results for android: Java JDK: installed . Android SDK: installed Android target: installed android-19,android-21,android-22,android-23,Google Inc.:Glass Development Kit Preview:19,Google Inc.:Google APIs:19,Google Inc.:Google APIs (x86 System Image):19,Google Inc.:Google APIs:21,Google Inc.:Google APIs:22,Google Inc.:Google APIs:23Forwhy
M
1

Your problem seems that Android Support Repository, Android Support Library and Google Repository are not installed or are out of date, install/update them and try again. TACO won't update them, so try doing it manually

OLD: Best thing you can do is install Microsoft TACO

npm install -g taco-cli
taco create myAwesomeApp
cd myAwesomeApp
taco platform add android
taco install-reqs android
taco build android

The important command is taco install-reqs android, it should install all you need for Android development or fix any problem you might have

If you don't want to use TACO, your problem seems that Android Support Repository, Android Support Library and Google Repository are not installed or are out of date, install/update them and try again.

Microbalance answered 21/10, 2015 at 11:16 Comment(3)
No, TACO is Tools for Apache COrdova, once it fix your android problems you can continue using cordovaMicrobalance
OK, doesn't sound so good being microsoft tool; but i'll check it out, thanksForwhy
See the edit, I don't think TACO will fix your problemMicrobalance
P
0

As you're already running cordova 5.3.3 chances are that you get rid of your build error when you update your plugins to the current versions. The cordova project has moved all official plugins to the NPM Registry

I don't know the exact issue of the "com.android.support:support-v4 Problem" but I have experienced several plugin build problems because of this support library as well.

You could also try to install this Plugin to resolve your issues.

One answer in this (nearly duplicate) Question recommends updating the Android SDK (good idea) and removing and adding the android platform (bad idea if you have customizations in the android folder and did not backup them)

Predial answered 21/10, 2015 at 8:38 Comment(4)
Thank you for your answer, what Is the command to update a plugin in cordova? thanxForwhy
You need to uninstall it with cordova remove <plugin_name> and the reinstall it.Mcchesney
This is most likely a different kind of problem. But if this answer solved your "com.android.support:support-v4 Problem" you should accept it to let others know about the solution.Mcchesney
No.. it didn't actually, basically if anything changed was installing the java jdk, but i need sudo, for some reasonForwhy
T
-1

faced same type of error but my android list sdk in command line given me Packages available for installation or update: 10 1- GPU Debugging tools, revision 1.0.3 2- Local Maven repository for Support Libraries, revision 28 3- Android Auto Desktop Head Unit emulator, revision 1.1 4- Google Play services, revision 29 5- Google Repository, revision 25 6- Google Play APK Expansion Library, revision 3 7- Google Play Billing Library, revision 5 8- Google Play Licensing Library, revision 2 9- Android Auto API Simulators, revision 1 10- Google Web Driver, revision 2

updating the android sdk solved my problem updated the following in my system using command android update sdk --no-ui --filter 1,2,5,6,7,8,9 or you can try updating all packages

Transformism answered 4/4, 2016 at 12:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.