Error building android platform with phonegap - android

I have phonegap 3.2.0-0.17.0 installed on Ubuntu 12.10.
For some reason, when I try to build the android platform to my local project on phonegap, I get the following error:
> phonegap local build android
[phonegap] adding the Android platform...
[error] An error occured during creation of android sub-project. Looks like your environment fully supports cordova-android development!
Creating Cordova project for the Android platform:
Path: platforms/android
Package: com.package.project_name
Name: project_name
Android target: android-17
Building cordova-3.2.0.jar
{ [Error: Command failed:
BUILD FAILED
/path/to/adt-bundle-linux-x86_64-20131030/sdk/tools/ant/build.xml:653: The following error occurred while executing this line:
/path/to/adt-bundle-linux-x86_64-20131030/sdk/tools/ant/build.xml:698: null returned: 127
Total time: 1 second
] killed: false, code: 1, signal: null }
Here my JAVA_HOME, ANT_HOME & PATH configuration for any suggestion:
export JAVA_HOME=/usr/lib/jvm/default-java
export ANT_HOME=/usr/local/apache-ant-1.9.2
export PATH=${PATH}:/path/to/adt-bundle-linux-x86_64-20131030/sdk/platform-tools:/path/to/adt-bundle-linux-x86_64-20131030/sdk/tools:${ANT_HOME}/bin
Can someone help me to solve this?
Thanks!

Related

Ionic2 - Android build failed

I was trying to build an Ionic2 app with Android platform on my Win 7 (32 bt) system.
I ran the ionic build android command in the CLI and the following error occurred :
...ionic build android
> ionic-hello-world# ionic:build D:\<path>
> ionic-app-scripts build
[20:12:32] ionic-app-scripts 1.0.0
[20:12:32] build dev started ...
[20:12:32] clean started ...
[20:12:32] clean finished in 10 ms
[20:12:32] copy started ...
[20:12:32] transpile started ...
[20:12:37] transpile finished in 5.47 s
[20:12:37] webpack started ...
[20:12:38] copy finished in 5.74 s
[20:12:49] webpack finished in 11.84 s
[20:12:49] sass started ...
[20:12:52] sass finished in 2.81 s
[20:12:52] build dev finished in 20.16 s
[20:12:58] tslint: D:/../src/app/app.component.ts, line: 3
Unused import: 'OneSignal'
L2: import { Platform } from 'ionic-angular';
L3: import { StatusBar, Splashscreen, OneSignal } from 'ionic-native';
ANDROID_HOME=C:\Users\<user-name>\AppData\Local\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_60
Subproject Path: CordovaLib
Starting a new Gradle Daemon for this build (subsequent builds will be faster).
FAILURE: Build failed with an exception.
* What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html
Please read the following process output to find out more:
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
Then as suggested I read the 'https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html' and created the gradle.properties file with the following
org.gradle.daemon=true
The error still persists with the same result !!!
What is going wrong ?? Please help .
Found the solution after a hour long R&D.
Basically as per 'https://cordova.apache.org/docs/en/latest/guide/platforms/android/' - As of cordova-android#4.0.0, Cordova for Android projects are built using Gradle. Earlier it was built using Apache Ant.
Now Gradle looks for latest Android SDK. When I removed the android platform and added again with ionic platform add android command - the CLI listed that the latest Android SDK ( in my case it was SDK 24 ) was not installed.
I installed the required SDK version using Android SDK Manager and subsequent add of Android Platform along with the cordova plugin smoothly installed without any error.
The CLI printed the following -
..ionic plugin add onesignal-cordova-plugin
Fetching plugin "onesignal-cordova-plugin" via npm
Installing "onesignal-cordova-plugin" for android
ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_121
Subproject Path: CordovaLib
Incremental java compilation is an incubating feature.
:clean
:CordovaLib:clean
BUILD SUCCESSFUL
Total time: 1.611 secs
Subproject Path: CordovaLib
Try using cordova platform add https://github.com/apache/cordova-android
Ive had to start using this command ever since updating Ionic.

Failed to find 'ANDROID_HOME' environment variable. Failed to find 'android' command in your 'PATH'

I'm trying to build the default Hello World phonegap project for android on my ubuntu system, but I am confronted by errors at every step.
SHORT VERSION:
I cannot create a phonegap project without sudo (not quite true--see below).
After creating a phonegap project with sudo, I cannot build android without sudo.
When I type "sudo phonegap build android", I lose my path settings, resulting in an error.
I have attempted a fix for this last problem by including the line "alias sudo='sudo env PATH=$PATH'" in.bashrc, as suggested in sudo changes PATH - why?, but it doesn't work. I also added ANDROID_HOME and PATH lines to .bash_profile, with no success.
I think the 'android' command actually is in my path.
Here are the last lines of my .bashrc:
export PATH="$HOME/Android/tools:$PATH"
export PATH="$HOME/Android/platform-tools:$PATH"
export ANDROID_HOME="$HOME/Android:$PATH"
alias sudo='sudo env PATH=$PATH'
I also have the following in ~/.bash_profile:
export PATH="$HOME/Android/tools:$PATH"
export PATH="$HOME/Android/platform-tools:$PATH"
export ANDROID_HOME="$HOME/Android:$PATH"
LONG VERSION:
gregory#gregory-1001PXD:~/javascript$ phonegap create phonetest
Error: EACCES, permission denied '/home/gregory/.config/configstore/update-notifier-cordova.json'
You don't have access to this file.
at Object.fs.openSync (fs.js:432:18)
at Object.fs.readFileSync (fs.js:286:15)
at Object.create.all.get (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/update-notifier/node_modules/configstore/index.js:34:26)
at Object.Configstore (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/update-notifier/node_modules/configstore/index.js:27:44)
at new UpdateNotifier (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/update-notifier/index.js:34:17)
at module.exports (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/update-notifier/index.js:123:23)
at checkForUpdates (/usr/local/lib/node_modules/phonegap/node_modules/cordova/src/cli.js:64:20)
at cli (/usr/local/lib/node_modules/phonegap/node_modules/cordova/src/cli.js:114:5)
at Object.<anonymous> (/usr/local/lib/node_modules/phonegap/node_modules/cordova/bin/cordova:41:1)
at Module._compile (module.js:456:26)
gregory#gregory-1001PXD:~/javascript$ sudo phonegap create phonetest
[sudo] password for gregory:
Creating a new cordova project.
gregory#gregory-1001PXD:~/javascript$ cd phonetest/
gregory#gregory-1001PXD:~/javascript/phonetest$ sudo phonegap build android
[phonegap] executing 'cordova build android'...
cp: no such file or directory: /home/gregory/javascript/phonetest/icon.png
Running command: /home/gregory/javascript/phonetest/platforms/android/cordova/build
[Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.]
ERROR building one of the platforms: Error: /home/gregory/javascript/phonetest/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /home/gregory/javascript/phonetest/platforms/android/cordova/build: Command failed with exit code 2
Bu I think the android command is in my PATH (it tab-completes).
NOTE: I can create a project without sudo if I remove the file update-notifier-cordova.json. But it still produces an error, as follows.
gregory#gregory-1001PXD:~/javascript$ sudo mv /home/gregory/.config/configstore/update-notifier-cordova.json ~/Documents/
gregory#gregory-1001PXD:~/javascript$ phonegap create phonetest
Creating a new cordova project.
gregory#gregory-1001PXD:~/javascript$ cd phonetest/
gregory#gregory-1001PXD:~/javascript/phonetest$ phonegap build android
[phonegap] executing 'cordova platform add --save android'...
Error: Failed to fetch platform android#~4.1.0
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: EACCES, open '/home/gregory/.cordova/lib/npm_cache/cordova-android/4.1.1/package/.npmignore'
[phonegap] executing 'cordova build android'...
Error: No platforms added to this project. Please use `cordova platform add <platform>`.
This is documented in their JIRA: https://issues.apache.org/jira/browse/CB-10062
Check the ownership of the file using:
ls -al /home/gregory/.config/configstore/update-notifier-cordova.json
If it is root, you may want to try reinstalling cordova - otherwise use the workaround suggested by running:
chmod 744 /home/gregory/.config/configstore/update-notifier-cordova.json

How to solve this errors Ant, add platform android and cordova build android failure

Here is a PATH in environment :
C:\Users\user\AppData\Roaming\npm;D:\work\SDK\SoftPhonegap\ADT\sdk\platform-tools;D:\work\SDK\SoftPhonegap\ADT\sdk\tools;D:\work\SDK\SoftPhonegap\apache-ant-1.9.5\bin;C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Java\jdk1.7.0_51\bin;C:\Program Files\Java\jdk1.8.0_45\bin;D:\work\SDK\SoftPhonegap\ADT\sdk\build-tools
A. Error log of cordova build android
BUILD FAILED
D:\work\SDK\SoftPhonegap\ADT\sdk\tools\ant\build.xml:601: The following error oc
curred while executing this line:
D:\work\SDK\SoftPhonegap\ADT\sdk\tools\ant\build.xml:542: Unable to resolve proj
ect target 'android-21'
Total time: 0 seconds
D:\work\SDK\SoftPhonegap\ADT\hello\platforms\android\cordova\node_modules\q\q.js
:126
throw e;
^
Error code 1 for command: cmd with args: /s /c "ant debug -f D:\work\SDK\SoftPho
negap\ADT\hello\platforms\android\build.xml -Dout.dir=ant-build -Dgen.absolute.d
ir=ant-gen"
ERROR building one of the platforms: Error: D:\work\SDK\SoftPhonegap\ADT\hello\p
latforms\android\cordova\build.bat: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: D:\work\SDK\SoftPhonegap\ADT\hello\platforms\android\cordova\build.bat: C
ommand failed with exit code 8
at ChildProcess.whenDone (C:\Users\user\AppData\Roaming\npm\node_modules\cor
dova\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)
B Error log of Ant
C:\Users\user>ant
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre1.8.
0_45\lib\tools.jar
Buildfile: build.xml does not exist!
Build failed
C. when add platform android
D:\work\SDK\SoftPhonegap\ADT\hello>cordova platform add android
npm http GET https://registry.npmjs.org/cordova-android/3.7.2
npm http 304 https://registry.npmjs.org/cordova-android/3.7.2
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms\android
Package: com.example.hello
Name: HelloWorld
Android target: android-21
Copying template files...
Project successfully created.
Installing "com.phonegap.plugins.PushPlugin" for android
Installing "com.salesforce" for android
Installing "org.apache.cordova.device" for android
Could not run SalesforceMobileSDK plugin android pre-install script
You are running node v0.10.25
You need to be running node 0.12 or above
You won't be able to successfully run: cordova build
Running SalesforceMobileSDK plugin android post-install script
The "android" utility does not exist at D:\work\SDK\SoftPhonegap\ADT\sdk\tools;D
:\work\SDK\SoftPhonegap\ADT\sdk\platform-tools\tools\android.bat. Make sure you
've properly installed the Android SDK.
I think you need to give platform_tools pah also, you should post your error log,
anyway here is how my PATH looks like
C:\Users\amitabhs\AppData\Roaming\npm;F:\Softs\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\platform-tools;F:\Softs\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\tools;F:\Softs\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\platforms;C:\Program Files\Java\jdk1.8.0_45\bin;C:\Program Files\apache-ant-1.9.5\bin;
check if it helps
Compile your project in https://build.phonegap.com/
There you have no problems with OS and can compile for all OS.
I use then for IOS compilation.
Solution:
Uninstall node v0.10.25
install node 0.12 or above
remove platform android (cordova platform rm android)
add platform android (cordova platform add android)
build android (cordova build android)
Done

Phonegap Command filed with exit code 8 - Ubuntu

I'm trying to do my first android app in javascript with [phonegap][1] (cordova).
But when I put "phonegap run android" it exits with error 8, this is the code, here is the pic: http://i.stack.imgur.com/qofsZ.png (can't post screen because of reputation):
giulio#cucina:~/Documenti/web/sveglia/sveglia$ phonegap run android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
/home/giulio/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:126
throw e;
^
Error: An error occurred while listing Android targets
at /home/giulio/.cordova/lib/android/cordova/3.5.1/bin/lib/check_reqs.js:87:29
at _rejected (/home/giulio/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:808:24)
at /home/giulio/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:834:30
at Promise.when (/home/giulio/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/home/giulio/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:752:41)
at /home/giulio/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:574:44
at flush (/home/giulio/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:419:13)
{ [Error: /home/giulio/.cordova/lib/android/cordova/3.5.1/bin/create: Command failed with exit code 8] code: 8 }
[error] /home/giulio/.cordova/lib/android/cordova/3.5.1/bin/create: Command failed with exit code 8
I've tried to follow these instructions: stackoverflow.com/questions/20323787/cordova-platform-add-android-not-working-while-listing-android-targets/21142421#21142421 and stackoverflow.com/questions/24380283/phonegap-run-android-create-command-failed-with-exit-code-8-linux, but again it doesn't work.
This is the bashrc (http://i.stack.imgur.com/mdLDY.png), I've put the code at the top:
export ANDROID_HOME="/media/giulio/Secondo\ Disco/Development/android-sdk-linux/tools"
export ANDROID_PLATFORM_TOOLS="/media/giulio/Secondo\ Disco/Development/android-sdk-linux/platform-tools"
export PATH="$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS:$PATH"
export PATH="$PATH:/usr/share/ant/bin"
~/.bashrc: executed by bash(1) for non-login shells.
...etc
I've already installed android packages, ant and everything necessary.
You're my last chance! D:
Export the two variables:
ANDROID_HOME and JAVA_HOME
And, in addition, put android platform-tools on the PATH, works for me.
In my case, it was something like this:
export ANDROID_HOME=/home/YOURUSER/sw/android/adt-bundle-linux-x86-20131030/sdk/
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386/
export PATH="/home/YOURUSER/sw/android/adt-bundle-linux-x86-20131030/sdk/platform-tools/:/home/YOURUSER/sw/android/adt-bundle-linux-x86-20131030/sdk/tools:tools:$PATH"

build error Cordova projects with Cordova 3.1.0-0.2.0

When I run my app on my android device after I have updated cordova plugins I get:
In the cli:
Result: 1
sim-android:
cordova -d run android
cordova library for "android" already exists. No need to download. Continuing.
Calling plugman.prepare for platform "android"
Error: ENOENT, no such file or directory '/home/robin/NetBeansProjects/local/plugins/org.apache.cordova.file'
at Object.fs.statSync (fs.js:684:18)
at /usr/lib/node_modules/cordova/node_modules/plugman/src/prepare.js:124:15
Preparing android project
Processing configuration changes for plugins.
Iterating over installed plugins: [ 'org.apache.cordova.device',
'org.apache.cordova.splashscreen',
'org.apache.cordova.file',
'org.apache.cordova.console',
'org.apache.cordova.battery-status',
'org.apache.cordova.contacts',
'org.apache.cordova.geolocation', at Array.forEach (native)
at Object.handlePrepare (/usr/lib/node_modules/cordova/node_modules/plugman/src/prepare.js:122:24)
at /usr/lib/node_modules/cordova/src/prepare.js:93:25
at _fulfilled (/usr/lib/node_modules/cordova/node_modules/q/q.js:798:54)
at self.promiseDispatch.done (/usr/lib/node_modules/cordova/node_modules/q/q.js:827:30)
at Promise.promise.promiseDispatch (/usr/lib/node_modules/cordova/node_modules/q/q.js:760:13)
at /usr/lib/node_modules/cordova/node_modules/q/q.js:821:14
'org.apache.cordova.network-information', at flush (/usr/lib/node_modules/cordova/node_modules/q/q.js:108:17)
'org.apache.cordova.globalization',
'org.apache.cordova.device-motion',
'org.apache.cordova.dialogs',
'org.apache.cordova.device-orientation',
'org.apache.cordova.media',
'org.apache.cordova.media-capture' ]
/home/robin/NetBeansProjects/local/nbproject/build.xml:272: exec returned: 1
BUILD FAILED (total time: 11 seconds)
Updating the plugins is the only thing that has been updated for the build to fail.
This is my plugins.properties file.
org.apache.cordova.AudioHandler=https://git-wip-us.apache.org/repos/asf/cordova-plugin-media.git
org.apache.cordova.geolocation=https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git
org.apache.cordova.console=https://git-wip-us.apache.org/repos/asf/cordova-plugin-console.git
Any help with this would be great, thanks.

Categories

Resources