Build Cordova project on Windows - android

I am trying to build a Cordova project on Windows using the steps I was given by the team who developed it.
Install Bower, Cordova CLI, Grunt CLI, SASS/Compass/sass-globbing gems
grunt build
cordova platforms add android
Then trying to run grunt emulate android but getting an error. I have the Android SDK installed and can fire up an emulator but I'm getting the following when trying to run that command:
Warning: Task "android" not found. Use --force to continue.
What am I doing wrong? I'm new to Cordova/PhoneGap development and all this interplay between packages is daunting.

You probably should run
cordova run android or grunt emulate:android
First part with cordova CLI should run all the time, and no need to use Grunt to launch application, if all assets are prepared.
Grunt part is just a guess work based on how I would organize Gruntfile.js and I could be wrong here. Without seeing more details, hard to tell you more.

Related

Can't build app with Ionic

I am no longer able to build my app and generate an apk anymore because an error shows up. Here is what happens when I try to build the app in the command prompt: Command Prompt
Can somebody please help me with this? Oh and this is what happens if I type ionic info in the command prompt:
Your environment has been set up for using Node.js 0.12.4 (x64) and npm.
C:\Users\Singh>ionic info
Your system information:
Cordova CLI: 5.1.1
Ionic CLI Version: 1.6.1
Ionic App Lib Version: 0.3.3
OS: Windows 7 SP1
Node Version: v0.12.4
C:\Users\Singh>
Try to remove the platform, and then add it again, and then build your application.
So, if you have android as targeted platform execute these commands:
ionic platform remove android
ionic platform add android
ionic build android
My son had a very similar problem, and we never did figure out what caused it. He ended up creating a brand new blank ionic project, and then just copying the www folder from the old project. It worked, and he was able to get things building again. If you try it, you'll also have to re-add your plugins, copy package.json and bower.json, and then rerun bower install and npm install. It's not pleasant, but it might be worth a shot if you're desperate.

Meteor Crosswalk build fails at second 'ant debug' step

I have a Meteor Cordova Android app which I'm trying to migrate and build using Crosswalk. I followed the steps from here:
https://meteor.hackpad.com/Building-Meteor-app-with-Crosswalk-kHKh4DzGxFQ
Until here, the build succeeds.
android update project --subprojects --path . --target "android-19"
ant debug
cd ..
ant clean
The next step, ant release or ant debug, the build fails with 100 javac errors. The error log is very close to whats mentioned here: https://github.com/meteor/meteor/issues/3076
The solution partly is here:
https://github.com/RayHuo/MyXwalk/wiki/MIGRATE-AN-EXISTING-CORDOVA-APPLICATION-TO-CROSSWALK-WITH-CORDOVA-3.4-OR-LATER.
Its says:
"And the solution is to changing the second ant debug to cordova build android"
But the android project folder is generated by Meteor and not Cordova, so I do not have cordova executable installed to run a cordova build android.
I still tried installing cordova separately and building it, but it simply says, 'its not a cordova based project'.
How do we do the last step using Meteor? There is another option to build it using Eclipse/ADT, but I want to figure this out within the Meteor build process.
I know I'm missing something simple here. Any help is greatly appreciated!
Thanks.
crosswalk provides a HelloWorld cordova/example via the bin/create
utility on the intel crosswalk website.
that CordovaLib directory can replace the meteor equivalent
,however the latest meteor version fails, so there maybe some
crosswalk/meteor version problems now to resolve.
HelloWorld appears to work with old version 8 crosswalk
and new meteor build
https://crosswalk-project.org/documentation/cordova/develop_an_application.html
Meteor 1.2 now supports CrossWalk with $ meteor add crosswalk

Cordova how to install app directly to Android device?

in case that i need to test cordova on app i must do this:
Run cordova build android
Go into android ADT (Eclipse)
Clean the project
And then run from eclipse on device.
Exist some less time consuming plugin or script for this?
Thanks for any advice.
You should be able to just do
cordova run android
from the command line. See here: Cordova Command Line docs

why $cordova prepare when use a new phonegap-cordova api(plugin)

Im new with phonegap, cordova and android. Im on mac, recently i install all the needs:
Phonegap 3.3.0-0.19.6
Cordova 3.3.1-0.4.1
Got Android SDK and running on eclipse with no problem. Then create a new Android application on eclipse for phonegap successfully, and running on a phone with android.
Then i create another app with cordoba(terminal), put 2 platforms android and ios, i run prepare etc.. and then import the project(android) into eclipse. At this point the app runs ok, so i proceed to install some plugins for testing (Notifications and Device)
https://cordova.apache.org/docs/en/3.0.0/cordova_device_device.md.html#Device
When i run the app with eclipse the examples always return
Uncaught TypeError: Cannot call method 'alert' of undefined
And its the same with device. So looking over the internet i found that if i run $cordova prepare will work, then i run the command, then run the app on eclipse and it work but always when i install a new plugin for testing i have to run cordova prepare, and the problem is that index.html rewrite with example hello world and i loose my code.
Any help over here, im doing ok?, how to install those plugins and make the test and dont have to run prepare all the time. (Please think on eclipse, i dont what to use terminal all the time)
I had the same exact problem and other posts suggestions didn't work for me.
I solved it by switching the steps a bit, despite the official docs and other posts.
If I add ALL the files AND the core plugins BEFORE I add the platforms, then adding the platforms takes these things with it into the new folder structures AND only build once from the command line before I open the project.
If I need to add anything I do it again. Although I can edit the www files without going through the process again, I do not expect the root www to perpetuate the platform www's. I just copy it myself into all the www folders. It shouldn't be this way but I think this is a well documented bug with multiple command line builds, for now and thats my working fix.
The recommended way is to edit html/js/css... in the root www folder of the project, not in the platfotms/xxx folders.
The reason is that if you have multiple platforms, you just need to modify in one place and cordova prepare or cordova build or phonegap build will propagate your code to all the platforms and update plugins.
If you have only android platform and want to be able to change code directly in eclipse for the platforms/android/assets/www folder, I suggest you create a shell script to
copy all the content of projectroot/platforms/android/assets/www to projectroot/www
run cordova prepare android
Then, instead of running cordova prepare android, you'll just have to run your script after you add new plugins.
Edit
I think there may be a better way for your problem.
You should be able to use plugman to install your plugins instead of cordova.
First you need to install plugman cli : npm install -g plugman
then install a plugin using
plugman -d --platform android --project projectname --plugin nameorurlofplugin
http://cordova.apache.org/docs/en/edge/plugin_ref_plugman.md.html
I had these issues too.
One approach I use now is:
Edit the index.html in the platform folders which is platform/iOS/appname/www and so. Then add plugins using the normal terminal way using cordova plugin add but always run the project using Xcode for iOS and eclipse and not from the terminal because then you will lose your code.
From my experience when you run using .xcodeproj or say android project the www on the inside is used and if you use cordova run ios from terminal the www on the outside will overwrite the www in the platform folders.
If you get xcode errors saying can't find so and so plugin files just move them to the path the error says xcode expects them to be in.

How to Build and run the cordova project with eclipse and run project for android

I have created the project with cordova CLI but i do not know where i need to change and how to run the cordova android project with eclipse for each platform. Thanks for helping
Before run the android project inside your Cordova Project you should know these things.
If you are making any changes in the Cordova Project then first you need to prepare the cordova. use the command cordova prepare
Then it changed in your config.xml (for android) automatic as you added or any changes you made. Do not make any change in your android project which exist inside your Cordova project. You can only make change inside the www folder of your Cordova project. And after made changed you need to make cordova prepare every time.
After prepare the cordova you can run the android project on device or emulator. For this you make sure you have made the path of android sdk for platforms-tools and tools in your environment system. If you not configure this path and add this two path in system environment .
Now run the android project on device use command cordova run android and run on emulator use this command cordova emulate android.
And if want to run on eclipse then you should import this android project of your workspace in eclipse. But if you again made changes in your cordova project then need to delete and again import the android project this switching happened every time so better to run through CLI.
I hope you got all things
Sunil's answer is good. I would like to add logging using Android Debug Bridge(adb).You may want to run:
adb logcat on a seperate shell window for logs after running cordova run android you need when you run into errors.This will produce huge logs, so I would recommend using:
adb logcat|grep Cordova

Categories

Resources