Install Cordova and example programs in Android 6, androidcordova

Source: Internet
Author: User

Install Cordova and example programs in Android 6, androidcordova
Cordova official website documentation

Http://cordova.apache.org/docs/en/5.0.0/guide_cli_index.md.html#The%20Command-Line%20Interface/

Official example:

Npm install-g phonegap-global installation of phonegap
Npm install-g cordova
Cordova create hello com. example. hello HelloWorld-d
Cd hello
Cordova platform add android
Cordova platforms ls-view supported platforms
# Cordova platform remove blackberry10 remove platform statement
Cordova build android
#-Compile all platforms using cordova build
Cordova emulate android

After the project is generated, you can use android eclipse to import the project:

Often see error handling change target version during installation


If you have this prompt, install the SDK android-22. Here, android-22 is too new. I changed the target version:

Test \ myapp \ platforms \ android \ project. properties

Target = android-21 # Here we will change the target version android. library. reference.1 = CordovaLib
Network exception

If this error occurs:

Try multiple downloads, which may be due to network problems.

Sdk missing


This error occurs because cordova uses android. webkit. ClientCertRequest. android sdk 21 must be installed.

Hello World

Modify index.html

<! Doctype html> 

You can add cordova events to the head:

<meta charset="utf-8"><meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" /><script type="text/javascript" src="cordova.js"></script><script type="text/javascript" charset="utf-8">  function onBodyLoad(){      document.addEventListener("deviceready",onDeviceReady,false);  }  function onDeviceReady(){      navigator.notification.alert("Cordova is ready!");  }</script>

Modify body

<body onload="onBodyLoad()"></body>

To handle errors, run the following command in the command line:

Adb logcat | find "Web Console"

The running result is as follows:

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.