![Android Emulator Mac Cordova Not Running Android Emulator Mac Cordova Not Running](https://cdn-images-1.medium.com/max/1200/1*oA9MVI5y0gUsSPiql7tjMQ.jpeg)
. Back.NET controls for Visual Studio in desktop, web, and native mobile. Best Value. Other Products.
Deliver a full reporting solution with extensive.NET API, data visualization, viewers, and designers. Take total control of your documents with high-speed, intuitive document APIs. Build powerful spreadsheet apps with components and designers. HTML5/JavaScript controls with support for Angular, React, and Vue. Specialized Extensions. Support & Learning. Cordova and Ionic offer some really useful features that allows web developer to write native applications for each platform using web languages.
Jan 26, 2017 - Building Apache Cordova apps for Android devices. Server Visual Studio Code Visual Studio for Mac Azure DevOps Services Windows. Run on an Android Device; Run on the Google Android Emulator; Run on the. If you did not enable the highlighted options, close Visual Studio, launch the. Android Emulators are software which let you install Android apps and games on your Mac. Thus, enabling you to run apps and play games made for Android on your system. Considering, the vast number of productive apps and great games for Android, it increases the amount of activities you can do on your Mac.
These apps aren't mobile websites, but apps that sit in the app store. Understanding and developing using Cordova and Ionic can be a little tricky at times, and I've found that getting your machine set up can be a bit cumbersome. In another, we discuss how you can use with NPM and Webpack to create applications targeting the most popular JavaScript application frameworks. In this article we've compiled a list of helpful guides for getting started with Cordova Ionic. Try Wijmo's JavaScript controls Download the latest version of Wijmo Step One: Download NodeJS Installing NodeJS NodeJS is a JavaScript runtime built on Chrome's JavaScript Engine.
Today, we'll be using the NodeJS package ecosystem called npm. This helps us get all the necessary libraries and frameworks onto our local development machine. At the time of this writing, npm is the largest ecosystem of open source libraries in the world.
Of course, Wijmo isn't open source, but we'll need npm to install the necessary files. Mac users: For OS X, download the.pkg file and take note of the last screen of the installer. Windows users: Download either the MSI or the exe, whichever you prefer. After you're done you'll most likely need to restart your computer. After you NodeJS installs, you can utilize the npm commands to get the packages. Mac users: you should be able to use npm right from terminal, assuming your PATH is configured correctly. Windows users: you can use the built-in command prompt or NodeJS command prompt.
Mac users: If you want to install globally, you need to use sudo, so make you sure you know what you’re downloading. Sudo npm install -g // -g the is for global If you want to be able to utilize the CLI, which we do. To ensure that npm is configured correctly, you can type: npm –-version Step Two: Configure the Path Configuring CLI For Mac After we've installed NodeJS, we want to configure our path or verify that the Path is set up the correct way. I broke mine the first time, so I'll show you how to fix it if you mess it up. If everything is set up correctly, you should see the version number displayed on the command line. If this is the case, you can skip down to the Ionic Cordova installation.
If your terminal is not finding npm, type the following commands into terminal: touch /.bashprofile open /.bashprofile This opens the.bashprofile file in your default text editor. It may be the case that your bashprofile is either empty or filled with a bunch of things; regardless, we want to make sure we have our /usr/local/bin inside it. When I originally ran mine it looked like this: /bin /usr/bin /usr/local/bin. You can verify the contents of your path by typing into the command prompt: echo $PATH. If suddenly you can do things like ls or pico, type the following export: PATH=/bin:/usr/bin:/usr/local/bin.and your basic commands will return.
Step Three: Install Cordova Once you've installed npm, installing Cordova on Windows and Mac is pretty straightforward. You can use npm to do this. In your command prompt, type: sudo npm install -g cordova. You may be asked to type in your admin password. (I'm not sure if you can add ionic at the end here and do it in one command.) The install will take a few minutes.
Step Four: Install Ionic. Next, install Ionic: sudo npm install -g ionic. If you had previously installed Ionic, you can run the updater tool: ionic lib update. Mac users: Next, make sure that your Xcode (if you're using Mac OSX) is downloaded and up to date. Windows users: If you already have an Android emulator or a Windows Phone emulator, just ensure that you're up to date. Configuring the iOS Simulator (Mac OSX only). Let’s get the npm packages that allow us to launch the iPhone sim from the terminal via Ionic: sudo npm install -g ios-sim.
You can verify that your ios-sim is installed correctly by typing: ios-sim –version. Now let's type in pwd to figure out where we are, and navigate to our desktop print working directory.
Step Five: Create your First Ionic App. Navigate to your desktop via the command prompt. Cd Desktop.
Now, let's make a new ionic application and use the sideMenu template we can also use tabs, Apptabs and Blank ionic start firstIonicApp sidemenu. This will download the template; use blank if you just want the structure. If we want to create a new template app, we type: ionic start myApp tabs. If we want to create one with a sidemenu template, we type: ionic start myApp sidemenu. The CLI contains a few flags, as well, which you can configure:.
Human readable name for the app (Use quotes around the name) -appname, -a. Package name set in the config ex: com.mycompany.myapp -id, -i. Do not create an app targeted for Cordova -no-cordova, -w.
Next, we want to navigate inside the folder: cd myApp && ls Step Six: Create Native Platforms The next step is to create some native platforms. For iOS: ionic platform add iOS For Android: ionic platform add Android Inside each respective platform folder, you should find your XCode and Android Studio projects. Step Seven: Run Your Application Running it on iOS Inside platform/ios/HelloCordova is the XCode project, but you don’t need to open it. We'll continue using the CLI to do our operations. Next step is to run the emulate: cordova emulate ios -target='iPhone-4s' iPhone-4s iPhone-5 iPhone-5s iPhone-6-Plus iPhone-6 iPad-2 iPad-Retina iPad-Air Resizable-iPhone Resizable-iPad. You should see your emulator launch: You'll want to consult the Apple developer docs to get the most recent list of emulators available to you. Running your application in the browser.
Since it's a JavaScript application, from the terminal you can type the following command: ionic serve This launches the Ionic webserver that allows you to debug you application. The server will reload the page every time you update a file. If your browser doesn’t launch, type in your URL in browser. Localhost.
From terminal, to quit out of the prompt, type: q Here's another neat feature of Ionic that allows you to see how Ionic changes the look and feel of your app. It's nice if you’re a Windows user or a Mac user without Android studio installed. Type with the labs flag: ionic serve –l. This launches your web browser, but it shows your website inside a iOS and Android window. Setting up Android Emulator and Android SDK I downloaded and installed Eclipse and the Java SDK.
You can use any IDE you want for the Android stuff. For Mac OSX You should be able to type Java into terminal and see what you need. While the Android SDK is downloading and installing, you can go ahead and start reading about. Learn about.
Setting up Android Studio. Mac OSX Users: Drag and drop Android Studio into the Applications folder. Open Android Studio and follow the setup wizard to install any necessary SDK tools. Depending on your security settings, when you attempt to open Android Studio, you might see a warning that says the package is damaged and should be moved to the trash. If this happens:. Go to System Preferences Security & Privacy.
Go to 'Allow applications downloaded from'. Select Anywhere. Open Android Studio again Installing Homebrew I tried installing all of the Android SDK and tools, but I've found that Brew was the easiest way. Mac users: The easiest way to install Brew is to type the following command into your terminal: ruby -e '$(curl -fsSL Android ANT Android ANT will allow you to build using the CLI. It creates an.apk file with a debug key so it's ready for installation onto an emulator or a device.
You can read more about Android ANT on their. Once you have Brew installed, installing Ant is as easy as typing the following commands: brew update brew install ant Android’s docs note that support for Ant as a build tool is ending.
They recommend that you migrate your app development projects to Android Studio. Android SDK. Once we have Android-Ant installed, we need to install the Android SDK. Once again, the easiest way to install Android-SDK on Mac OSX is to use Brew: brew install android-sdk For Windows Java JDK. Install the (not the JRE). We need to create an environment variable for the Java JDK in JAVAHOME and point it to the root folder where the JDK is located. From Android Docs: If you installed the JDK into C: Program Files Java jdk7, set JAVAHOME to be this path.
![Mac cordova visalia Mac cordova visalia](https://developer.android.com/studio/images/run/avd-settings-quickboot-callout_2x.png)
Add the JDK's bin directory to the PATH variable. Following the previous assumption, this should be either%JAVAHOME% bin or the full path C: Program Files Java jdk7 bin Android Studio and SDK. Download Android SDK:. Once you have the exe installed, you’ll need to configure your Windows systems.
Follow the setup wizard to install Android Studio and any necessary SDK tools. On some Windows systems, the launcher script does not find where Java is installed.
If you encounter this problem, you need to set an environment variable indicating the correct location. Select Start menu Computer System Properties Advanced System Properties. Open Advanced tab Environment Variables. Add a new system variable JAVAHOME that points to your JDK folder. For example: C: Program Files Java jdk1.7.021. Android ANT.
Just like we did with the Java SDK, we need to add ANT to our PATH. Copy the ANT installation to our C: drive, then add the following to your PATH. Like so: C: apache-ant-1.9.2 bin Step Eight: Test Android Now that we have an IDE, Android-SDK, and Apache-ANT installed, we should be able to set up and AVD using Android manager. The easiest way to launch the manager is to type: android. This should launch a SDK window.
At this point we want to install all of the necessary tools and SDKs. You can see Ionic Cordova’s documentation to find exactly what you need; I downloaded the entire SDK.
From this point you should be able to create an Android project. Creating and Running and Android Application. If you haven’t built your Android application yet, go ahead and type: ionic platform add android.
Once your android platform is added, type: ionic run android This should launch the emulator.
Android Platform Guide This guide shows how to set up your SDK environment to deploy Cordova apps for Android devices, and how to optionally use Android-centered command-line tools in your development workflow. You need to install the Android SDK regardless of whether you want to use these platform-centered shell tools or cross-platform Cordova CLI for development. For a comparison of the two development paths, see the. For details on the CLI, see. Requirements and Support Cordova for Android requires the Android SDK which can be installed on OS X, Linux or Windows. See the Android SDK's.
Cordova's latest Android package supports up to Android 25. The supported Android API Levels and Android Versions for the past few cordova-android releases can be found in this table: cordova-android Version Supported Android API-Levels Equivalent Android Version 7.X.X 19 - 27 4.4 - 8.1 6.X.X 16 - 26 4.1 - 8.0.0 5.X.X 14 - 23 4.0 - 6.0.1 4.1.X 14 - 22 4.0 - 5.1 4.0.X 10 - 22 2.3.3 - 5.1 3.7.X 10 - 21 2.3.3 - 5.0.2 Please note that the versions listed here are for Cordova's Android package, and not for the Cordova CLI. To determine what version of Cordova's Android package is installed in your Cordova project, run the command cordova platform ls in the directory that holds your project. As a general rule, Android versions become unsupported by Cordova as they dip below 5% on Google's. Installing the Requirements Java Development Kit (JDK) Install.
When installing on Windows you also need to set JAVAHOME Environment Variable according to your JDK installation path (see ) Gradle As of Cordova-Android 6.4.0, is now required to be installed to build Android. When installing on Windows, you need to add Gradle to your path, (see ) Android SDK Install. Detailed installation instructions are on Android's developer site. Adding SDK Packages After installing the Android SDK, you must also install the packages for whatever you wish to target.
It is recommended that you install the highest SDK version that your version of cordova-android supports (see ). Open the Android SDK Manager (run sdkmanager from the terminal) and make sure the following are installed:. Android Platform SDK for your targeted version of Android.
Android SDK build-tools version 19.1.0 or higher. Android Support Repository (found under 'Extras') See Android's documentation on for more details. Setting environment variables Cordova's CLI tools require some environment variables to be set in order to function correctly. The CLI will attempt to set these variables for you, but in certain cases you may need to set them manually. The following variables should be updated:.
Set the JAVAHOME environment variable to the location of your JDK installation. Set the ANDROIDHOME environment variable to the location of your Android SDK installation. It is also recommended that you add the Android SDK's tools, tools/bin, and platform-tools directories to your PATH OS X and Linux On a Mac or Linux, you can use a text editor to create or modify the /.bashprofile file. To set an environment variable, add a line that uses export like so (substitute the path with your local installation). $ source /.bashprofile Windows These steps may vary depending on your installed version of Windows.
Close and reopen any command prompt windows after making changes to see them reflected. Click on the Start menu in the lower-left corner of the desktop. In the search bar, search for Environment Variables and select Edit the system Environment Variables from the options that appear.
In the window that appears, click the Environment Variables button To create a new environment variable:. Click New. And enter the variable name and value To set your PATH:. Select the PATH variable and press Edit. Add entries for the relevant locations to the PATH.
For example (substitute the paths with your local Android SDK installation's location). $ cordova run -emulator Configuring Gradle As of [email protected], Cordova for Android projects are built using. For instructions on building with Ant, refer to older versions of the documentation. Please note that Ant builds are deprecated as of the Android SDK Tools 25.3.0. Setting Gradle Properties It is possible to configure the Gradle build by setting the values of certain that Cordova exposes. The following properties are available to be set: Property Description cdvBuildMultipleApks If this is set, then multiple APK files will be generated: One per native platform supported by library projects (x86, ARM, etc).
This can be important if your project uses large native libraries, which can drastically increase the size of the generated APK. If not set, then a single APK will be generated which can be used on all devices cdvVersionCode Overrides the versionCode set in AndroidManifest.xml cdvReleaseSigningPropertiesFile Default: release-signing.properties Path to a.properties file that contains signing information for release builds (see ) cdvDebugSigningPropertiesFile Default: debug-signing.properties Path to a.properties file that contains signing information for debug builds (see ). Useful when you need to share a signing key with other developers cdvMinSdkVersion Overrides the value of minSdkVersion set in AndroidManifest.xml. Useful when creating multiple APKs based on SDK version cdvBuildToolsVersion Overrides the automatically detected android.buildToolsVersion value cdvCompileSdkVersion Overrides the automatically detected android.compileSdkVersion value You can set these properties in one of four ways:. By setting environment variables like so. // In /platforms/android/build-extras.gradle ext. CdvMinSdkVersion = 20 The latter two options both involve including an extra file in your Android platform folder.
In general, it is discouraged that you edit the contents of this folder because it is easy for those changes to be lost or overwritten. Instead, these two files should be copied from another location into that folder as part of the build command by using the beforebuild. Extending build.gradle If you need to customize build.gradle, rather than edit it directly, you should create a sibling file named build-extras.gradle. This file will be included by the main build.gradle when present.
This file must be placed in the android platform directory ( /platforms/android), so it is recommended that you copy it over via a script attached to the beforebuild. Here's an example. VersionCode = MAJOR.
10000 + MINOR. 100 + PATCH If your application has enabled the cdvBuildMultipleApks Gradle property (see ), the version code of your app will also be multiplied by 10 so that the last digit of the code can be used to indicate the architecture the apk was built for.
This multiplication will happen regardless of whether the version code is taken from the android-versionCode attribute or generated using the version. Be aware that some plugins added to your project (including cordova-plugin-crosswalk-webview) may set this Gradle property automatically. Please Note: When updating the android-versionCode property, it is unwise to increment the version code taken from built apks. Instead, you should increment the code based off the value in your config.xml file's android-versionCode attribute. This is because the cdvBuildMultipleApks property causes the version code to be multiplied by 10 in the built apks and thus using that value will cause your next version code to be 100 times the original, etc. Signing an App First, you should read the. Using Flags To sign an app, you need the following parameters: Parameter Flag Description Keystore -keystore Path to a binary file which can hold a set of keys Keystore Password -storePassword Password to the keystore Alias -alias The id specifying the private key used for signing Password -password Password for the private key specified Type of the Keystore -keystoreType Default: auto-detect based on file extension Either pkcs12 or jks These parameters can be specified using the command line arguments above to the build or run commands.
Note: You should use double - to indicate that these are platform-specific arguments, for example: cordova run android -release - -keystore=./my-release-key.keystore -storePassword=password -alias=aliasname -password=password. Using build.json Alternatively, you could specify them in a build configuration file ( build.json) using the -buildConfig argument to the same commands. Here's a sample of a build configuration file. StoreFile=relative/path/to/keystore.p12 storePassword=SECRET1 storeType=pkcs12 keyAlias=DebugSigningKey keyPassword=SECRET2 storePassword and keyPassword are optional, and will be prompted for if omitted. Debugging For details on the debugging tools that come packaged with the Android SDK, see. Additionally, Android's developer documentation for provides an introduction for debugging the portion of your app running in the Webview.
Opening a Project in Android Studio Cordova for Android projects can be opened in the Android IDE,. 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. Once it finishes importing, you should be able to build and run the app directly from Android Studio. See and for more details.
Platform Centered Workflow cordova-android includes a number of scripts that allow the platform to be used without the full Cordova CLI. This development path may offer you a greater range of development options in certain situations than the cross-platform cordova CLI. For example, you need to use shell tools when deploying a custom Cordova WebView alongside native components.
Before using this development path, you must still configure the Android SDK environment as described in above. For each of the scripts discussed below, refer to for more information on their arguments and usage. Each script has a name that matches the corresponding CLI command.
For example, cordova-android/bin/create is equivalent to cordova create. To get started, either download the cordova-android package from. To create a project using this package, run the create script in the bin folder. $ cordova-android/bin/create The created project will have a folder named cordova inside that contains scripts for the project-specific Cordova commands (e.g. Run, build, etc.). Additionally, the project will feature a structure different from that of a normal Cordova project.
Notably, /www is moved to /assets/www. To install plugins in this project, use the. Upgrading Refer to article for instructions to upgrade your cordova-android version. Lifecycle Guide Cordova and Android Native Android apps typically consist of a series of that the user interacts with. Activities can be thought of as the individual screens that make up an application; different tasks in an app will often have their own activity. Each activity has its own lifecycle that is maintained as the activity enters and leaves the foreground of a user's device.
In contrast, Cordova applications on the Android platform are executed within a Webview that is embedded in a single Android activity. The lifecycle of this activity is exposed to your application through the document events that are fired.
The events are not guaranteed to line up with Android's lifecycle, but they can provide guidelines for saving and restoring your state. These events roughly map to Android callbacks as follows: Cordova Event Rough Android Equivalent Meaning deviceready onCreate Application is starting (not from background) pause onPause Application is moving to the background resume onResume Application is returning to the foreground Most other Cordova platforms have a similar concept of lifecycles and should fire these same events when similar actions happen on a user's device. However, Android presents some unique challenges that can sometimes show up thanks to the native Activity lifecycle. What makes Android different?
In Android, the OS can choose to kill activities in the background in order to free up resources if the device is low on memory. Unfortunately, when the activity holding your application is killed, the Webview in which your application lives will be destroyed as well. Any state that your application is maintaining will be lost in this case. When the user navigates back to your application, the Activity and Webview will be recreated by the OS, but state will not be automatically restored for your Cordova app. For this reason, it is imperative that your application be aware of the lifecycle events that are fired and maintain whatever state is appropriate to make sure a user's context in your app is not lost when they leave the application. When can this happen? Your application is susceptible to being destroyed by the OS whenever it leaves the sight of the user.
There are two main situations in which this can occur. The first and most obvious case is when the user presses the home button or switches to another application. However, there is a second (and much more subtle) case that certain plugins can introduce. As noted above, Cordova applications are usually confined to the single activity that contains the Webview. However, there are instances in which other activities may be launched by plugins and temporarily push the Cordova activity to the background.
These other Activities are typically launched in order to perform a specific task using a native application installed on the device. For example, the launches whatever camera activity is natively installed on the device in order to take a photo. Reusing the installed camera application in this way makes your application feel much more like a native app when the user tries to take a photo. Unfortunately, when the native Activity pushes your app to the background there is a chance the OS will kill it. For a clearer understanding of this second case, let's walk through an example using the camera plugin. Imagine you have an application that requires the user to take a profile photo. The flow of events in the application when everything goes as planned will look something like this:.
The user is interacting with your app and needs to take a picture. The camera plugin launches the native camera activity. The Cordova activity is pushed to the background (pause event is fired). The user takes a photo. The camera activity finishes. The Cordova activity is moved to the foreground (resume event is fired).
The user is returned to your application where they left off However, this flow of events can be disrupted if a device is low on memory.