import and develop an ionic project in android studio - android

I'm trying to create a Ionic project.I build the project successfullyionic build androidThen I import the folder platform/android in android studio as the answer told me on Internet.But the answer is about ionic1.The folder platform/android/assets in an Ionic2 project is totally different from an Ionic1 project.There is no any html pages in assets folder but index.html.
Does anyone know the right way to develop an Ionic2 project in android studio?

When you build a project using Ionic 2, it bundles all the code into a file called main.js using Browserify, which you can find in /assets/www/build/main.js. This process was not included in Ionic 1, hence the difference.
With this scenario, I am not sure how to get it to work with Android Studio, because the Ionic project is not an Android Studio project and disabling the bundling process does not seem like a great idea.
Is there a reason why you are using Android Studio to develop your Ionic app? Why not use an editor or IDE that is more specialized for editing web apps? For example, Ionic has a great integration with Visual Studio.

Related

Where to place jars in Cordova app developed in Visual Studio?

I am trying to create cordova app in visual studio, because I just want to explore. I have very good idea on Cordova CLI, eclipse and Android Studio environments. My goal is to add my own custom plugin to the Visual Studio Cordova project and execute my existing code.
With the help of below link, I successfully added my custom plugin.
https://taco.visualstudio.com/en-us/docs/manage-plugins/#Custom
Apart from js files, my custom plugin also needs some native(android) jars, which I am going to add manually in Eclipse/Android Studio.
My problem here is - I don't find any libs folder in Visual Studio environment (as I am newbie), can some one let me know where exactly I need to required jars.

Building Ionic framework in android studio

I'm trying to create a hybrid application through the IONIC framework which displays multiple moving graphics implemented through HTML5 Canvas and JS. But, the animation renders very slowly in mobiles (even those with 1GB RAM).
We have identified and downloaded FastCanvas (Cordova/PhoneGap plugin). We followed the instructions given in the URL - https://github.com/phonegap/phonegap-plugin-fast-canvas. But under "Adding FastCanvas to Your Application" we hit a roadblock when we come to instructions 3 and 4 as there are no Java folders in my project.
The example (HTML5 Game) given in the url is done through PhoneGap which has the mentioned folder structure and it works fine when we build through Android studio.
We have tried to build our project (done through ionic framework) through Android Studio but, gradle build system was unable to identify the framework. Request someone to please guide me further to solve this issue since, I'm struggling to come up with a solution for long.
Note: We have already tried Canvas, JS, CSS3 and wizCanvas plugin for the animation but, the output is same - slow.
Whoo-hoo.
After a long struggle, this is what finally worked for me:
Opening a Project in Android Studio
Cordova for Android projects can be opened in the Android IDE, Android Studio. This can be useful if you wish to use Android Studio's built in Android debugging/profiling tools or if you are developing Android plugins. Please note that when opening your project in Android studio, it is recommended that you do NOT edit your code in the IDE. This will edit the code in the platforms folder of your project (not www), and changes are liable to be overwritten. Instead, edit the www folder and copy over your changes by running cordova build.
Plugin developers wishing to edit their native code in the IDE should use the --link flag when adding their plugin to the project via cordova plugin add. This will link the files so that changes to the plugin files in the platforms folder are reflected in your plugin's source folder (and vice versa).
To open a Cordova for Android project in Android Studio:
Launch Android Studio.
Select Import Project (Eclipse ADT, Gradle, etc).
Select the Android platform directory in your project (/platforms/android).
For the Gradle Sync question you can simply answer Yes.
(If prompted to update gradle from v2.3 to 3.3. click Update)
Once it finishes importing, you should be able to build and run the app directly from Android Studio. See Android Studio Overview and Building and Running from Android Studio for more details.
Refs:
https://cordova.apache.org/docs/en/latest/guide/platforms/android/
https://www.codeproject.com/articles/1068176/step-by-step-guide-to-build-ionic-hybrid-app-using

Import Cordova project in Android Studio

I am trying to create a Cordova project. After creating the project cordova create myProject I would like to open it in Android Studio. The problem is ... it doesn't work.
The CordovaLib will not build with various errors package android.* does not exist.
Does anyone know how to import a cordova project in Android Studio?
Unfortunately the accepted answer is a bit out of date. Using Cordova v5.3.3 (it probably works on all versions > 5) it is much the same process a building and then entering XCode for an iOS application now - the build system has moved to gradle.
Before opening in Android Studio
cordova build android
Then just open up the project using File > Open and pointing to the (yourProjectDir)/Platforms/Android directory.
If you are using an older version of the cordova android platform you might need to run
cordova platform android update
To get moved to the gradle build system which is compatible with the current version of Android Studio
Make sure you import the "platform/android" directory underneath your cordova project (and you want to Import Project, not Open Project).
You will at least need to run
cordova prepare android
before doing the import
cordova build android
will also work, but it will create some ant directories which will not be used by Android Studio and you will have to actively ignore the files when importing otherwise you will get extra libraries in your project). Although I haven't imported a Cordova app into android studio recently, it definitely works in the Community edition of Intellij which Android Studio is based on (I did it yesterday with a project built from scratch with Cordova 3.5). I can't think of any of the additional features in Android Studio that would be useful that aren't in Intellij, as most of the additions which haven't been backported to Intellij are in the preview space which isn't going to work with Cordova anyway (all it is going to preview is a blank webkit view).
All the answers above seem to refer to the cli. However, to actually have your project in android studio so that you can harness the power of the android studio, this is what I would suggest you do:
Please see my most relevant answer here...
Building Ionic framework in android studio
We have some troubles on importing Ionic project to android studio because we have add android platform with SUDO command, and because of it, android studio dont have access privileges to read files.
In my case just do sudo chmod -Rf 777 ionicFolder android studio can import project successful.
I hope this help some one with this problem.

Eclipse can't create project from existing code android

I've created by command line a new phonegap application.When I try to get it by eclipse from android existing code it can't recognise as a android project.
Have I build my phonegap app before?
Phonegap project's folders are:
.cordova
hooks
merges
platforms
plugins
www
phonegap create [optional params] will setup a blank project space. To add platforms to this project you must run phonegap platform add [ios/android/wp8]. Then depending on the platform and how you wish to develop it, you run either phonegap prepare or phonegap build.
In your case, since you wish to import to Eclipse, you will want to run:
phonegap platform add android
phonegap build
Then in Eclipse you can browse to /PROJECT_PATH/platforms/android and import your project.

Creating a Phonegap based Android ap in Android Studio

I've dabbled with Phonegap using Eclipse and the ADT plugins in the past and I'm now trying to get my head around doing this in the new Android Studio IDE.
Since Phonegap v3 seems to rely on some kind of NodeJS commandline installation thingy, of which I know absolutely nothing about, I've downloaded Phonegap v2.9 instead. Also since Android Studio is so new and the documentation seems to only cover importing existing Eclipse projects or projects built using Phonegap's commandline, I'm instead trying to follow old Eclipse documentation.
To get to the point, I've created a project in Android Studio and verified that it runs. I've then created /assets/www and copied cordova.js and a basic index.html file in. I've copied cordova-2.9.0.jar in to /libs and right clicked to 'add as library'. Finally, I've amended MainActivity.java and AndroidManifest.xml accordingly.
The problem though is that when the build gets to 'import org.apache.cordova.*;' in my MainActivity.java file, it's erroring out with 'Gradle: package org.apache.cordova does not exist'.
Could somebody please point me in the direction of some documentation on creating a Phonegap ap using Android Studio (rather than importing in from Eclipse or from something created via Phonegap commandline), or even just describe how I'm supposed to edit the build.gradle file so that Gradle can find Cordova?
Much appreciated.
Ric is really easy to work with Phonegap and ANDROID Studio.
Here is what i am doing:
Creating Phonegap project: phonegap create testproject com.testproject.name Name;
Enter Project directory: cd testproject;
Add Android platform: phonegap build android;
You have your phonegap project ready. Now open Android Studio. Select Import project and follow instructions. If you don't have any plugins added in your project it's preaty pushing NEXT till you get to the end.
That's all. If you need more information tell me will be happy to help you.
If you prefer snapshot you can find a very easy to follow tutorial here:
Phonegap and Android studio

Categories

Resources