Apache Cordova and ADT - Update 'www' folder - android

I am developing an Android app using Apache Cordova 3.6.0.
I have followed the instructions available here and here to create, build and run my app.
I realized there are two folders which store HTML, CSS and JS files: www and platforms/android/assets/www:
According to this answer, I should modify only www because the command $ cordova run android will overwrite platforms/android/assets/www.
When I run my app through ADT, the folder platforms/android/assets/www is not updated.
How can I make ADT update this directory? What am I missing?

The linked answer is correct. You should only modify the content of the root www folder.
But you will have to build your app before you run it to make your changes take effect in the platforms/android/assets/www folder by running:
$ cordova build
or cordova build android.

FIRST SET OF WWW folder:
it contains your customized file ,from which you are developing the application.U must make the changes here.
SECOND SET OF WWW folder:
these are generated when u install a plugin with sample.(A working example)

Related

How to launch a Cordova project with full rebuilding of plugins?

I'm working on a Cordova plugin. As a plugin can't be executed, I'm using a Cordova project to test it. I found that running a Cordova project will not reimport and rebuild plugins, so currently I'm doing this:
rmdir \"./plugins/my-plugin\" /q /s
cordova platform remove android
cordova platform add android
cordova run android --device
Did I miss something or Cordova really doesn't have a command to fully rebuild everything before running the project?
Unfortunately, cordova will check your plugins folder only when adding or updating a plugin or platform. Then it will build and copy the needed plugin(s) into the designated OS in the platforms folder.
By your script I assume the source of the plugin is outside of the project folder. So the script you're using should do the work. But if I may give you a better solution would be as follows:
Create a Symlink/shortcut of the source folder for your plugin into the plugins folder, so you'll not need to remove the folder and stress the disk into copying files everytime you want to run the update.
Your "update" script should delete only the installed plugin folder at platforms/android/platform_www/plugins/my-plugin and it'll make the update far more quickier than removing and adding the platform again.

www folder empty in ionic project

I am trying to create a basic ionic project. I have used the command
ionic start myProj blank to create myself a blank project. I am referring to a tutorial where is shows that the www folder should have css, js and other folders in them. I don't see ay in my project structure.
I have tried reinstalling ionic. Did not help. Currently I have installed
Ionic - 2.2.3
Node - v6.10.2
I am using Atom editor to view and edit the contents
ionic start mproj blank will create files in src directory..
www folder will get files once you build for eg: ionic serve.
This will have build folder containing transpiled and minified css and js files.
ionic has changed considerably from 2 to 3.x.. Your code should work with minor changes if it is old tutorial..just compare with official docs

In phonegap On adding a new plugin if I rebuild my app it is removing the total project and creating a new one

Im trying to add a new plugin in phonegap, in order to work a new plugin we should rebuild the app. But if i rebuild the app my entire project is removed and it is creating a new one.
how can i use the plugin without rebuild or how can i rebuild app without loosing my code.
Im trying to add the splashscreen plugin.
First off all: I would recommend you to get a deeper look into Cordova. Therefore you need to read the Cordova Documentation.
The reason for just having a clear index and things like that is, that the command cordova build will copy all files from the root www folder into your platforms. That means, that you probably have worked in the www folders from your platforms.
Your folder structure is sth like this
So if you run the cordova build command it will copy all files from the www folder (2.) in your folders for your platforms (1.). If you now have not worked in the root www folder, it'll just copy the files which were created while you build the project the first time.
Normaly the Plugins you installed are available directly after you installed them - without a rebuild. So i would first recommend you to update your cordova (npm update -g cordova). After that you should create a new project and copy your files from your last project into the root www folder. A workflow for that should look like follows:
cordova create testProject com.example.com testProject
cd testProject
cordova platform add [platform you need]
cordova plugin add org.apache.cordova.splashscreen [plugins you need] - please note: Since Cordova is on V5, all Plugins are available via npm so the new command for installing plugins looks like: cordova plugin add cordova-plugin-splashscreen.
After you added all now you're copying the index and css file from your project into your new www root folder
Now you run cordova build
If you want an extra plugin now, which you have not installed when you created your project, you close all files your IDE (Xcode or Android Studio) and then move into your project with your terminal/console. There you can add a plugin now and it should be available after it is installed with cordova plugin add cordova-plugin-* without the build command!
Hope that helped you, let me know if you need further information!

Cordova platform add creates platforms folder in wrong path

I have a simple project with some files in a www/ folder.
In the same folder i create my cordova project with the call
cordova create cordova com.test.app Testapp --copy-from=www/
This creates my cordova folder with the content from www/ inside the cordova/www/ folder which is fine so far.
Now if i call
cordova platform add android
it fails looking for plugins/android.json in my root folder not inside cordova/.
After that i figured out, that this command created the platforms/android folder inside my root folder instead of the cordova/ folder.
So its pointing to the parent folder even if im inside cordova/ calling the platform add command. Whats going wrong here? I thought cordova always works relative to the current path. But now it seems its getting up to the parent folder adding platforms there and looking for the plugins folder. How can i fix that?
I'm using Cordova 3.5.0 and have set up android-sdk with java 1.7.0_65 and ant in PATH and JAVA_HOME.
I can easily create the demo HelloWold project and add platforms, but not in my web project.
I would like to automate it by calling a shell script, but since cordova points to the wrong folder, it doesn't work.
Appreciate any help.
I think what you don't understand here is that when you run the command
cordova create cordova com.test.app Testapp --copy-from=www
the cli will use your www folder to create a new project in the newly created folder named "cordova".
So you have to type cd cordova before you can run any cli command.
I have successfully ran the following commands:
cordova create cordova com.test.app Testapp --copy-from=www
cd cordova
cordova platform add android
And I would also suggest you use an other name instead of cordova as parameter of the create command :
cordova create testapp com.test.app Testapp --copy-from=www

cordova create VS cordova-ios/bin/create

On OSX I want to create a PhoneGap app to run on iOS and Android.
I installed cordova (3.0.0) and phonegap (3.0.0-0.14.0) using npm.
Following the CLI guide I can create my app using
cordova create hello com.example.hello HelloWorld
then add platforms
cordova platform add ios
cordova platform add android
It works well but I'd like to use XCode as IDE. I read the IOS platform guide and saw I can create my app using
./path/to/cordova-ios/bin/create /path/to/hello com.example.hello HellowWorld
I can't execute that command if the folder already exists, so I removed it first. I then tried adding android to it but it doesn't work (Current working directory is not a Cordova-based project.). I then noticed that the content of the directories are really different depending on the tool used.
Is there an easy way to create an XCode project and still be able to use the CLI to build for Android and iOS?
I was able to create a project for ios using the CLI against the bin directory of the ios platform as in your example EXCEPT, I had to create an empty folder first. Try this..
./create ~/My-Project/name of empty project folder com.example.appname. "Project Name"
You can:
create a project using cordova create projectname
add ios support with cordova platform add ios
navigate to projectname/platforms/ios and open the .xcodeproj file in XCode
to use XCode as the IDE.
cordova platform add ios uses the create script under the covers.
The issue you will run into is that if you make changes to the html, css, or js files under projectname/platforms/ios, you will have to manually push those changes back to projectname/www. Or you can only make changes to projectname/www and use cordova prepare to push them to your ios directory (and your android directory).
You'd also need to decide how you want to handle version control--will you do it yourself with a command line client, or within your IDE?

Categories

Resources