I have an Ionic 2 app. If I change one piece of .ts code I had to perform the folowing steps:
Remove platform;
Ionic platform add android;
Ionic run android or import gradle on android studio;
This process is very slow. How can automatically change .ts code without remove platform?
You don't have to remove and re-add, just do ionic build android.
In any case your workflow doesn't look right, why are you working with the built platform on android studio instead of just working with the files in your appdirectory?
Related
In our Ionic project we have created a few actual native views for IOS and Android. We did this by adding them to the Xcode and Android Studio projects them selves.
We are now having portability problems getting it to run on another machine. It suggests doing a ionic platform rm ios and ionic platform add ios
By doing this all the custom views and functionality applied to the projects directly will be overwritten.
What is the proper way to correct this problem? I understand its likely a plugin, but how would you go about creating a plugin which is an actual native view?
I am starting to learn Ionic, and on building my first application, when typing the
# ionic platform add android
it says that the command has been renamed. My question is, what was it changed with?
In the tutorial I follow, it says to execute the commands
# ionic platform add android
# ionic build android
# ionic run android
On searching the web, I have come across the command
# ionic cordova run android
and it also said that cordova was moved to a CLI which also has to be installed.
But what about "add" and "build"? They are not required anymore?
Thank you.
I believe you are using latest Ionic version, 3.6.0 and above. Since then Ionic cli commands have renamed from
ionic platform add android to ionic cordova platform add android
For all the commands append cordova after ionic keyword.
For list of command, refer to the documentation here at https://ionicframework.com/docs/cli/
Your tutorial commands are outdated. But you can still follow them, but just append cordova after ionic keyword
ionic platform add android becomes ionic cordova platform add android
ionic build android becomes ionic cordova build android
ionic run android becomes ionic cordova run android
"But what about "add" and "build"? They are not required anymore?" - You still need them for adding platforms/plugins.
add is used for adding platforms/plugins. For ex: To add ios platform you use ionic cordova platform add ios
build is used for Build (prepare + compile) an Ionic project for a given platform. For ex: To build ios you need ionic cordova build ios
Note: you can replace ios with android or vise versa in any of the above commands.
Since you started learning check this website out, might be a good place to start - https://ionicacademy.com/
Now "ionic" is renamed with "ionic cordova".
So use:
ionic cordova platform add android
ionic cordova run android
***for run on windows****
ionic cordova platform add browser
ionic serve
I'm using Ionic to build an application, and have built a plugin to linkup the html-side and java-side.
However, every time I make changes to the plugin, I need to ionic platform rm android, than ionic platform add android, hence to refresh the plugin in corresponding android project.
Is there any command or method to help me quickly to achieve such purpose?
I'm writting a Project about get location in Android, i was do a same Project by phonegap with Cordova Plugin for get location and i feel it was great..
So, I want to use Cordova Plugin in exist Native Android Project, anyway to do this ?
Not sure if I understand your question correctly but short answer is Yes. You should be able to create a Cordova project:
cordova create hello com.example.hello HelloWorld
Then simply add the android platform:
cd hello
cordova platform add android
Cordova will create the native android project and you can program using native Android stuff and you should also be able to use the Cordova plugins if you wish.
Obviously, a phonegap/cordova plugin consist of 3 different parts :
1. plugin.xml file (manifest file)
2. a common javascript interface to bridging between our phonegap project with native device API, and
3. native code for each supported platform
So, in order to your case, you can find the native code for android (JAVA file) in src/android from the top directory of your plugin
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?