Building phone gap app for Android failing - java

When trying to build my phone gap app for android using
sudo phonegap build android
it fails with this error:
:compileDebugJava
/Users/youssefsami/Library/Mobile Documents/com~apple~CloudDocs/Developer/Mobile Apps/UzuConvert/platforms/android/src/org/apache/cordova/inappbrowser/InAppBrowser.java:120: error: cannot find symbol
|| Config.isUrlWhiteListed(url)) {
^
symbol: method isUrlWhiteListed(String)
location: class Config
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
FAILED
FAILURE:
Build failed with an exception.
* What went wrong:
Execution failed for task ':compileDebugJava'.
>
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
Total time: 5.607 secs
/Users/youssefsami/Library/Mobile Documents/com~apple~CloudDocs/Developer/Mobile Apps/UzuConvert/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/youssefsami/Library/Mobile Documents/com~apple~CloudDocs/Developer/Mobile Apps/UzuConvert/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/youssefsami/Library/Mobile Documents/com~apple~CloudDocs/Developer/Mobile Apps/UzuConvert/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/youssefsami/Library/Mobile Documents/com~apple~CloudDocs/Developer/Mobile Apps/UzuConvert/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/youssefsami/Library/Mobile Documents/com~apple~CloudDocs/Developer/Mobile Apps/UzuConvert/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)
I tried setting the java_home to the java alias in lib exec but still nothing. Any ideas on what maybe causing the problem?

It's because your InAppBrowser plugin is out date and probably out of sync with a newer version of the Cordova Android platform than when you first installed the plugin. I was getting the same issue with cordova-android#4.0.0 and 0.5.3 of InAppBrowser.
Fix is to first remove plugin
cordova plugin rm org.apache.cordova.inappbrowser
Then add it again (it should reinstall with the latest version the cordova CLI has in my case it grabbed 0.6). You can check the version in the RELEASENOTES.md in the plugins/org.apache.cordova.inappbrowser/ folder.
cordova plugin add org.apache.cordova.inappbrowser
You will need to remove the android platform and re-add it before building again so it doesn't keep the old version of the plugin.
cordova platform rm android
and
cordova platform add android
Now build again and the error should have gone.
EDIT: I just noticed at the top of your question you are using phonegap. Since you tagged with cordova (and thats what I use) I answered with cordova commands, but I'm guessing almost the same process applies with Phonegap.

Same problem with cordova-android#4.0.0
Thank's JDawgg your solution's better than mine, but if someone still have the bug you can use cordova-android#3.6.4 like this :
cordova platform remove android
then
cordova platform add android#3.6.4
you must have android 4.2.2 sdk installed
Finally
sudo phonegap build android

In case someone is using Meteor and came across the same problem, martijnwalraven suggests removing the older version of cordova-plugin-inappbrowser and add the most recent one:
$ meteor remove cordova:cordova-plugin-inappbrowser
$ meteor add cordova:cordova-plugin-inappbrowser#1.0.1
This did the trick for me!

Related

I can't do npx react-native run-android, Java error; Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'. LINUX

There were lots of Mapping new... logs, so i deleted a big chunk, because I exceeded the available characters
(I'm not sure if this is the problem) It says it's something related to the licences, but I already accepted them all, as far as I know.
In the images I show you what I've installed throught Android Studio, everything seems fine.
npx react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 863 file(s) to forward-jetify. Using 2 workers...
info JS server already running.
/bin/sh: 1: /home/u/platform-tools/adb: not found
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Observed package id 'system-images;android-29;google_apis;x86' in inconsistent location '/home/u/Android/Sdk/system-images/android-29/google_apis/x86' (Expected '/home/u/system-images/android-29/google_apis/x86')
Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Observed package id 'tools' in inconsistent location '/home/u/Android/Sdk/tools' (Expected '/home/u/tools')
Checking the license for package Android SDK Build-Tools 30.0.2 in /home/u/licenses
Warning: License for package Android SDK Build-Tools 30.0.2 not accepted.
Checking the license for package Android SDK Platform 30 in /home/u/licenses
Warning: License for package Android SDK Platform 30 not accepted.
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;30.0.2 Android SDK Build-Tools 30.0.2
platforms;android-30 Android SDK Platform 30
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: /home/u
* 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 1m 38s
error Failed to install the app. Please accept all necessary Android SDK licenses using Android SDK Manager: "$ANDROID_HOME/tools/bin/sdkmanager --licenses".
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;30.0.2 Android SDK Build-Tools 30.0.2
platforms;android-30 Android SDK Platform 30
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: /home/u
* 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 1m 38s
at makeError (/home/u/Desktop/workdir/Math_App/mathapp/node_modules/#react-native-community/cli-platform-android/node_modules/execa/index.js:174:9)
at /home/u/Desktop/workdir/Math_App/mathapp/node_modules/#react-native-community/cli-platform-android/node_modules/execa/index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (/home/u/Desktop/workdir/Math_App/mathapp/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
at async Command.handleAction (/home/u/Desktop/workdir/Math_App/mathapp/node_modules/#react-native-community/cli/build/index.js:192:9)
info Run CLI with --verbose flag for more details.
It basically indicates it's missing build-tools;30.0.2 Android SDK Build-Tools 30.0.2 platforms;android-30 Android SDK Platform 30
Install them throught Android-Studio, and everything should work.
Addionaty to that, I'd another problem (probably unrelated to the one on top, but I'll still add it here)
So, now if I try again npx react-native run-android the following error pops us
[adb]: Cannot run program "/home/u/platform-tools/adb": error=2, No such file or directory
platform-tools lives inside ~/Android/Sdk, not inside ~/ .
Basically it means that the path is wrong. Fix for that is here

Why are the licenses not accepted for Android SDK Platform 26 and Android SDK Build Tools 27.0.1?

I can't seem to run the android module, and I get the following:
$ cordova run android
Android Studio project detected
cordova-android-support-gradle-release: Android platform: V7+
cordova-android-support-gradle-release: Wrote custom version '27.+' to /path/to/platforms/android/app/build.gradle
cordova-android-support-gradle-release: Wrote custom version '27.+' to /path/to/platforms/android/cordova-android-support-gradle-release/norsan-cordova-android-support-gradle-release.gradle
ANDROID_HOME=/usr/lib/android-sdk
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
studio
Subproject Path: CordovaLib
Subproject Path: app
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
Observed package id 'build-tools;debian' in inconsistent location '/usr/lib/android-sdk/build-tools/27.0.1' (Expected '/usr/lib/android-sdk/build-tools/debian')
Observed package id 'build-tools;debian' in inconsistent location '/usr/lib/android-sdk/build-tools/27.0.1' (Expected '/usr/lib/android-sdk/build-tools/debian')
Checking the license for package Android SDK Build-Tools 27.0.1 in /usr/lib/android-sdk/licenses
Warning: License for package Android SDK Build-Tools 27.0.1 not accepted.
Checking the license for package Android SDK Platform 26 in /usr/lib/android-sdk/licenses
Warning: License for package Android SDK Platform 26 not accepted.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':CordovaLib'.
> You have not accepted the license agreements of the following SDK components:
[Android SDK Platform 26, Android SDK Build-Tools 27.0.1].
Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 5s
/path/to/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':CordovaLib'.
> You have not accepted the license agreements of the following SDK components:
[Android SDK Platform 26, Android SDK Build-Tools 27.0.1].
Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 5s
It looks like specific paths on my system are not what the androidsdk program expected, and I'm unsure if I should manually create these paths or if I should look further with what I can do with package managers and installations.
So I try:
$ androidsdk "build-tools;27.0.1" "platforms;android-26"
SDK_ROOT=/home/galen/snap/androidsdk/21/AndroidSDK
Picked up _JAVA_OPTIONS: -Duser.home=/path/to/snap/androidsdk/21
Warning: File /path/to/snap/androidsdk/21/.android/repositories.cfg could not be loaded.
[=======================================] 100% Computing updates...
But I still get the same error afterward. I'm not sure if the warning relevant or not.
I've also tried:
$ androidsdk --licenses
SDK_ROOT=/path/to/snap/androidsdk/21/AndroidSDK
Picked up _JAVA_OPTIONS: -Duser.home=/path/to/snap/androidsdk/21
Warning: File /home/galen/snap/androidsdk/21/.android/repositories.cfg could not be loaded.
All SDK package licenses accepted.======] 100% Computing updates...
Why are the accepted licenses not acknowledged, and how do I resolve the Cordova error?

Android Studio Not Prompting Device on Run

I am trying to run my application on either an emulator or my device. When I click the "run" button at the top of Android Studio, the app is not running but simply listing the message below:
/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/bin/java "-Dgradle.home=/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1" -Dtools.jar=/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/lib/tools.jar -Didea.launcher.port=7533 "-Didea.launcher.bin.path=/Applications/Android Studio.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/groovy-all-2.4.4.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/ant-1.9.6.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/ant-launcher-1.9.6.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-base-services-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-base-services-groovy-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-cli-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-core-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-docs-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-installation-beacon-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-jvm-services-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-launcher-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-logging-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-messaging-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-model-core-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-model-groovy-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-native-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-open-api-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-process-services-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-resources-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-tooling-api-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-ui-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-wrapper-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-announce-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-antlr-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-build-comparison-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-build-init-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-code-quality-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-dependency-management-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-diagnostics-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-ear-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-ide-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-ide-native-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-ide-play-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-ivy-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-jacoco-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-javascript-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-jetty-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-language-groovy-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-language-java-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-language-jvm-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-language-native-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-language-scala-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-maven-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-osgi-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-platform-base-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-platform-jvm-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-platform-native-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-platform-play-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-plugin-development-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-plugin-use-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-plugins-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-publish-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-reporting-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-resources-http-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-resources-s3-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-resources-sftp-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-scala-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-signing-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-sonar-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-test-kit-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-testing-base-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-testing-jvm-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-testing-native-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-tooling-api-builders-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/ivy-2.2.0.jar:/Applications/Android Studio.app/Contents/lib/idea_rt.jar" com.intellij.rt.execution.application.AppMain org.gradle.launcher.GradleMain --build-file /Users/troychuinard/Code/FanPolls/app/build.gradle
Incremental java compilation is an incubating feature.
:app:help
Welcome to Gradle 2.14.1.
To run a build, run gradle <task> ...
To see a list of available tasks, run gradle tasks
To see a list of command-line options, run gradle --help
To see more detail about a task, run gradle help --task <task>
BUILD SUCCESSFUL
Total time: 8.841 secs
This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html
Process finished with exit code 0
The prompt is never appearing that asks me to select a deployment target. What is the setting in Android Studio to enable?
To enable the Deployment Target Dialog go to Run -> Edit Configuration -> Android App (app) -> Target: Open Select Deployment Target Dialog
Besides that you also have to enable developer mode on your device and have the drivers installed via the SDK manager or the manufacturer.
To check if your device is recognized you can use adb devices and it should be listed.
The adb is located under the platform-tools e.g.
C:\Users\You\AppData\Local\Android\sdk\platform-tools
I found that the android build tools version 25.0.0 resolves this issue, I was previously using 25.0.1 and it was not loading the device chooser:
android {
compileSdkVersion 24
buildToolsVersion '25.0.0'
}
Anyone able to run with the latest build tools?

Ionic Android build stopped working

My Ionic/Cordova app has all of a sudden stopped building on Android after updating the Ionic and Cordova CLI. I've spent the last 2 days searching Google for a solution but I couldn't find anything that has helped. I'm assuming it's something to do with Cordova now using Gradle to build instead of Apache Ant. My Android SDK and build tools are all up to version 22, Gradle 2.2, Ant 1.9.4, JDK 8.
Other details:
Cordova CLI: 5.1.1
Ionic CLI Version: 1.6.1
Ionic App Lib Version: 0.3.3
OS: Mac OS X Yosemite
Node Version: v0.12.7
When I run ionic build android, I get this error:
FAILURE: Build failed with an exception.
* Where:
Script '/platforms/android/CordovaLib/cordova.gradle' line: 128
* What went wrong:
A problem occurred evaluating root project 'android'.
> No match found
* 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: 1.426 secs
/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /platforms/android/gradlew with args: cdvBuildDebug,-b,/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /platforms/android/cordova/build: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: /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:134:23)
You might need to set the android-versionCode in your config.xml file. I had a similar issue that was resolved by changing the code from "0.0.1" to "1". Apparently Android wants a single integer value.
In my config.xml I had to change this:
<widget id="com.acme.appname" version="0.0.1" android-versionCode="0.0.1" ios-CFBundleVersion="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
to this:
<widget id="com.acme.appname" version="0.0.1" android-versionCode="1" ios-CFBundleVersion="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
android-versionCode
I hope this helps.

Can't build cordova projects

I have a problem with setting up the work environment for Cordova on Windows 7 for Android. I use NetBeans 8 and followed this guide: Link Here
New project -> Cordova -> Hello World Template.
Whenever I try to build a Cordova project (in NetBeans) I get this message:
BUILD FAILED
C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\build.xml:90: Cannot find C:\Users\Administrator\SkyDrive\Skolegang\Dataingeniør\Android\adt-bundle-windows-x86_64-20130729\sdk\tools\ant\build.xml imported from C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\build.xml
Total time: 0 seconds
C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\cordova\node_modules\q\q.js:126
throw e;
Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\cordova\run.bat: Command failed with exit code 8
at ChildProcess.whenDone (C:\Users\Administrator\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:131:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
Command finished with error code 8: C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\cordova\run.bat --emulator
C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\nbproject\build.xml:272: exec returned: 1
BUILD FAILED (total time: 47 seconds)
I have googled it for hours but can't seem to find a solution. Some people get some of the same errors(not exact, but similar), but the solutions did not work for me. One issue was regarding Java 8 and ant versions beneath 1.9.0 (I use Node 0.10.26, java 1.7.0_25, cordova 3.5.0-0.2.4 and ant 1.9.4). I also tried to create a new project with the console (CMD), but it gives the exact same error when I build. It's no problem to create the project, nor adding Android as a platform, the problem is building the project. I think the environment variables are set correctly since the java, node, ant and cordova commands work fine in cmd/powershell, and the check_reqs.bat said that the environment was fine.
It's this line that creates the error: <import file="${sdk.dir}/tools/ant/build.xml" />. This is the rest of the message: Cannot find C:\Users\Administrator\SkyDrive\Skolegang\Dataingeniør\Android\adt-bundle-windows-x86_64-20130729\sdk\tools\ant\build.xml imported from C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\build.xml.
Here is the error I get in the command window (not using NetBeans):
PS C:\Users\Administrator\Desktop\test\fakeApp> cordova build android
Running command: C:\Users\Administrator\Desktop\test\fakeApp\platforms\android\cordova\build.bat
Buildfile: C:\Users\Administrator\Desktop\test\fakeApp\platforms\android\build.xml
BUILD FAILED
C:\Users\Administrator\Desktop\test\fakeApp\platforms\android\build.xml:90: Cannot find C:\Users\Administrator\SkyDrive\
Skolegang\Dataingeni├©r\Android\adt-bundle-windows-x86_64-20130729\sdk\tools\ant\build.xml imported from C:\Users\Admini
strator\Desktop\test\fakeApp\platforms\android\build.xml
Total time: 0 seconds
Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,C:\Users\Administrator\Desktop\test\fakeApp\platforms\androi
d\build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: C:\Users\Administrator\Desktop\test\fakeApp\platforms\android\cordova\build.bat: Command failed with exit code 2
at ChildProcess.whenDone (C:\Users\Administrator\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\s
rc\cordova\superspawn.js:131:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
I thought maybe it was a path issue since I have a special letter in the path were the NetBeansProjects are stored (and it's pretty long too), but creating a test directory at C:\ and creating the project with the command window gave the same error. I'm new at Cordova so I'm sure there's an easy solution, thanks in advance.
I solved it, though I tried to create a cordova project outside the OneDrive folder I did not think of the SDK path (which also were stored in OneDrive). By moving the SDK files to C: (the path could probably not contain the special letter 'ø') and changing the path of the environment variables (and the SDK path in NetBeans) it now runs perfectly.

Categories

Resources