Cordova Environment Configuration (Android)

Source: Internet
Author: User

    1. 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 )
    2. Creating a project Create hello
    3. CD Hello
    4. installing the Java Development Kit (JDK),Android SDK
    5. 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

    1. 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

    1. 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);

}

}

    1. 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)

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.