- Open command Line install global Cordova NPM install-g Cordova ( do not use cnpmhere, will cause the installation is not complete, there are many pits )
- Creating a project Create hello
- CD Hello
- installing the Java Development Kit (JDK),Android SDK
- Setting Environment Variables System Variables - new red font for your own path
Variable Name: Java_home
Variable value:D:\Program Files\java\jdk1.8.0_73?
Variable Name: Sdk_home
Variable value:F:\BaiduYunDownload\ADT-BUNDLE-WINDOWS-X86_64-20140702\SDK
variable name:path
Variable Value:
D:\Program Files\java\jdk1.8.0_73\bin; F:\BaiduYunDownload\adt-bundle-windows-x86_64-20140702\sdk\tools; F:\BaiduYunDownload\adt-bundle-windows-x86_64-20140702\sdk\platform-tools(note semicolon)
variable name:classpath
Variable Value:
D:\Program Files\java\jdk1.8.0_73\lib; D:\Program Files\java\jdk1.8.0_73\lib\tools.jar; D:\Program Files\java\jdk1.8.0_73\lib\dt.jar(note semicolon)
6. Error: Missing platform 26
7. Download the latest Android 8.0.0 (API 26) from the SDK Manager.exe in android-sdk-windows.7z
8.
9.android Update SDK--no-ui--all--filter "Extra-android-m2repository" ( useless )
download gradle-4.2-all.zip Decompression, configure the PATH Path=c:\program in the environment variable files\gradle-x.x\bin
11.hello ( project ) >platforms>android>cordova>lib>builders>gradlebuilder.js Found below
var distributionurl = process.env[' Cordova_android_gradle_distribution_url ' | | ' Https\\://services.gradle.org/distributions/gradle-3.3-all.zip ';
Change to:
var distributionurl = process.env[' Cordova_android_gradle_distribution_url ' | | ' File:///D:/work/gradle-3.3-all.zip ';
Download it from the Internet and load it locally according to the version
- the index.html in the
<meta http-equiv= "Content-security-policy" content= "default-src ' self ' data:gap:https://ssl.gstatic.com ' Unsafe-eval '; Style-src ' self ' unsafe-inline '; MEDIA-SRC *; Img-src ' self ' data:content:; " >
Delete or change to:
<meta http-equiv= "Content-security-policy" >
otherwise JS cannot load successfully
- Call the plugin ---- camera
Cordova Plugin Add Cordova-plugin-camera
<button onclick= "Takephoto ()" in html > photo </button>
in JS
function Takephoto () {
Navigator.camera.getPicture (takesuccess, Takefail, {
DestinationType:Camera.DestinationType.FILE_URI
});
callback after successful photo shoot
function Takesuccess (Imageuri) {
Console.log (' success ' + Imageuri);
document.getElementById (' M1 '). Src=imageuri;
}
Callback after failure
function Takefail (message) {
Navigator.notification.alert (" photo failed, Reason:" + message);
}
}
- invoking a plug- in---- opening a Web page in a browser
Cordova Plugin Add Cordova-plugin-inappbrowser
<button onclick= "Cordova. Inappbrowser.open (' http://www.baidu.com ', ' _blank ', ' location=yes ') ' > Test inappbrowser </button>
Custom plug-in development
http://m.blog.csdn.net/qq_23179075/article/details/77104276
Cordova Environment Configuration (Android)