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.