准备工具
jdk
node
sdk
ant
gradle :https://services.gradle.org/distributions/
上面工具安装完 配置环境变量
JAVA_HOME
C:\Program Files\Java\jdk1.8.0_144
CLASSPATH
.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar
MAVEN_HOME
H:\fuck\apache-maven-3.3.3
path
;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;%MAVEN_HOME%\bin;
ANDROID_HOME
C:\Program Files (x86)\Android\android-sdk
path
%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\tools;
ant_home
E:\apache-ant-1.10.1
path
%ant_home%\bin;
GRADLE_HOME
E:\gradle-4.2
path
%gradle_home%\bin;
先配置 cnpm 启动 node.js 窗口
npm install -g cnpm --registry=https://registry.npm.taobao.org
下载配置好sdk avd
安装ionic corvado
C:\Users\Administrator>cnpm install -g cordova ionic
Downloading cordova to C:\Users\Administrator\AppData\Roaming\npm\node_modules\c
ordova_tmp
Copying C:\Users\Administrator\AppData\Roaming\npm\node_modules\cordova_tmp\_cor
dova@7.0.1@cordova to C:\Users\Administrator\AppData\Roaming\npm\node_modules\co
rdova
Installing cordova's dependencies to C:\Users\Administrator\AppData\Roaming\npm\
node_modules\cordova/node_modules
[1/8] editor@1.0.0 installed at node_modules\_editor@1.0.0@editor
[2/8] q@1.0.1 installed at node_modules\_q@1.0.1@q
[3/8] nopt@3.0.1 installed at node_modules\_nopt@3.0.1@nopt
[4/8] configstore@2.1.0 installed at node_modules\_configstore@2.1.0@configstore
[5/8] cordova-common@2.0.3 installed at node_modules\_cordova-common@2.0.3@cordo
va-common
[6/8] update-notifier@0.5.0 installed at node_modules\_update-notifier@0.5.0@upd
ate-notifier
[7/8] insight@0.8.2 installed at node_modules\_insight@0.8.2@insight
[cordova-app-hello-world@3.12.0] download ShasumNotMatchError: real sha1:774fa64
cd4944a6512328d4f181273ba75675c0b not equal to remote:270e06b67b2ae94bcfee6592ed
39eb42303d186f (cordova-app-hello-world@3.12.0), fail count: 1
[npm@2.15.12] download ShasumNotMatchError: real sha1:a457dac3ebc55c67849015fb32
b57701ae5ccd39 not equal to remote:df7c3ed5a277c3f9d4b5d819b05311d10a200ae6 (npm
@2.15.12), fail count: 1
[8/8] cordova-lib@7.0.1 installed at node_modules\_cordova-lib@7.0.1@cordova-lib
deprecate insight@0.8.2 › node-uuid@^1.4.7 Use uuid module instead
Recently updated (since 2017-09-14): 3 packages (detail see file C:\Users\Admini
strator\AppData\Roaming\npm\node_modules\cordova\node_modules\.recently_updates.
txt)
2017-09-20
→ insight@0.8.2 › request@^2.40.0(2.82.0) (03:39:30)
2017-09-16
→ cordova-lib@7.0.1 › cordova-serve@1.0.1 › express@4.15.4 › finalhandle
r@~1.0.4(1.0.5) (11:03:46)
2017-09-15
→ cordova-lib@7.0.1 › cordova-serve@1.0.1 › express@4.15.4 › proxy-addr@
1.1.5 › forwarded@~0.1.0(0.1.2) (10:17:54)
All packages installed (400 packages installed from npm registry, used 1m, speed
369.03kB/s, json 356(668.49kB), tarball 23.97MB)
[cordova@7.0.1] link C:\Users\Administrator\AppData\Roaming\npm\cordova@ -> C:\U
sers\Administrator\AppData\Roaming\npm\node_modules\cordova\bin\cordova
Downloading ionic to C:\Users\Administrator\AppData\Roaming\npm\node_modules\ion
ic_tmp
Copying C:\Users\Administrator\AppData\Roaming\npm\node_modules\ionic_tmp\_ionic
@3.10.3@ionic to C:\Users\Administrator\AppData\Roaming\npm\node_modules\ionic
Installing ionic's dependencies to C:\Users\Administrator\AppData\Roaming\npm\no
de_modules\ionic/node_modules
[1/8] tslib@^1.7.1 installed at node_modules\_tslib@1.7.1@tslib
[2/8] opn@^5.1.0 installed at node_modules\_opn@5.1.0@opn
[3/8] semver@^5.3.0 installed at node_modules\_semver@5.4.1@semver
[4/8] os-name@^2.0.1 installed at node_modules\_os-name@2.0.1@os-name
[5/8] @ionic/discover@^0.3.0 installed at node_modules\_@ionic_discover@0.3.1@@i
onic\discover
[6/8] chalk@^2.0.0 installed at node_modules\_chalk@2.1.0@chalk
[7/8] rimraf@^2.6.1 installed at node_modules\_rimraf@2.6.2@rimraf
fsevents@1.1.2 download from binary mirror: {"module_name":"fse","module_path":"
./lib/binding/{configuration}/{node_abi}-{platform}-{arch}/","remote_path":"./v{
version}/","package_name":"{module_name}-v{version}-{node_abi}-{platform}-{arch}
.tar.gz","host":"https://npm.taobao.org/mirrors/fsevents"}
platform unsupported @ionic/cli-utils@1.10.2 › chokidar@1.7.0 › fsevents@^1.0.
0 Package require os(darwin) not compatible with your platform(win32)
[fsevents@^1.0.0] optional install error: Package require os(darwin) not compati
ble with your platform(win32)
[8/8] @ionic/cli-utils@1.10.2 installed at node_modules\_@ionic_cli-utils@1.10.2
@@ionic\cli-utils
Recently updated (since 2017-09-14): 5 packages (detail see file C:\Users\Admini
strator\AppData\Roaming\npm\node_modules\ionic\node_modules\.recently_updates.tx
t)
2017-09-19
→ @ionic/cli-utils@1.10.2 › inquirer@3.3.0 › external-editor@^2.0.4(2.0.5
) (21:27:58)
2017-09-18
→ @ionic/cli-utils@1.10.2 › inquirer@^3.2.3(3.3.0) (22:58:23)
2017-09-16
→ @ionic/cli-utils@1.10.2 › express@4.15.4 › finalhandler@~1.0.4(1.0.5) (
11:03:46)
2017-09-15
→ @ionic/cli-utils@1.10.2 › express@4.15.4 › proxy-addr@1.1.5 › forwarde
d@~0.1.0(0.1.2) (10:17:54)
→ @ionic/cli-utils@1.10.2 › ws@^3.1.0(3.2.0) (14:22:17)
All packages installed (232 packages installed from npm registry, used 28s, spee
d 186kB/s, json 224(379.13kB), tarball 4.79MB)
[ionic@3.10.3] link C:\Users\Administrator\AppData\Roaming\npm\ionic@ -> C:\User
s\Administrator\AppData\Roaming\npm\node_modules\ionic\bin\ionic
创建项目
C:\Users\Administrator>ionic start myApp sidemenu
√ Creating directory .\myApp - done!
[INFO] Fetching app base
(https://github.com/ionic-team/ionic2-app-base/archive/master.tar.gz)
√ Downloading - done!
[INFO] Fetching starter template sidemenu
(https://github.com/ionic-team/ionic2-starter-sidemenu/archive/master.tar
.gz)
√ Downloading - done!
√ Updating package.json with app details - done!
√ Creating configuration file ionic.config.json - done!
[INFO] Installing dependencies may take several minutes!
> npm install
√ Running command - done!
> git init
? Connect this app to the Ionic Dashboard? No
> git add -A
> git commit -m "Initial commit" --no-gpg-sign
Next Steps:
Go to your newly created project: cd .\myApp
C:\Users\Administrator>
$ cd myApp
$ ionic cordova platform add android
$ ionic build android
C:\Users\Administrator>cd myApp
C:\Users\Administrator\myApp> ionic cordova platform add android
[INFO] Enabling Cordova integration.
> ionic config set integrations.cordova {} --json --force
[OK] integrations.cordova set to {} in .\ionic.config.json!
> cordova platform add android --save
√ Running command - done!
> ionic cordova resources android --force
√ Collecting resource configuration and source images - done!
√ Filtering out image resources that do not need regeneration - done!
√ Uploading source images to prepare for transformations - done!
√ Generating platform resources: 18 / 18 complete - done!
√ Modifying config.xml to add new image resources - done!
C:\Users\Administrator\myApp>ionic build android
[WARN] ionic build is for building web assets and takes no arguments. See ionic
build --help.
Ignoring argument android. Perhaps you meant ionic cordova build android?
[INFO] Running app-scripts build: --platform android
[13:51:00] build dev started ...
[13:51:00] clean started ...
[13:51:00] clean finished in 4 ms
[13:51:00] copy started ...
[13:51:00] transpile started ...
[13:51:02] transpile finished in 2.06 s
[13:51:02] preprocess started ...
[13:51:02] deeplinks started ...
[13:51:02] deeplinks finished in 12 ms
[13:51:02] preprocess finished in 12 ms
[13:51:02] webpack started ...
[13:51:02] copy finished in 2.23 s
[13:51:09] webpack finished in 6.70 s
[13:51:09] sass started ...
[13:51:10] sass finished in 754 ms
[13:51:10] postprocess started ...
[13:51:10] postprocess finished in 15 ms
[13:51:10] lint started ...
[13:51:10] build dev finished in 9.60 s
> ionic cordova prepare android
> cordova prepare android
You have been opted out of telemetry. To change this, run: cordova telemetry on.
[13:51:13] lint finished in 2.73 s
C:\Users\Administrator\myApp>
先启动avd
复制 gradle-3.3-all.zip 到
$ ionic cordova emulate android
C:\Users\Administrator\myApp>ionic cordova emulate android
[INFO] Running app-scripts build: --platform android --target cordova
[14:00:16] build dev started ...
[14:00:16] clean started ...
[14:00:16] clean finished in 5 ms
[14:00:16] copy started ...
[14:00:16] transpile started ...
[14:00:17] transpile finished in 1.81 s
[14:00:17] preprocess started ...
[14:00:17] deeplinks started ...
[14:00:18] deeplinks finished in 11 ms
[14:00:18] preprocess finished in 12 ms
[14:00:18] webpack started ...
[14:00:18] copy finished in 2.10 s
[14:00:25] webpack finished in 7.34 s
[14:00:25] sass started ...
[14:00:26] sass finished in 802 ms
[14:00:26] postprocess started ...
[14:00:26] removed unused font files
[14:00:26] postprocess finished in 12 ms
[14:00:26] lint started ...
[14:00:26] build dev finished in 10.02 s
> ionic cordova prepare android
> cordova prepare android
You have been opted out of telemetry. To change this, run: cordova telemetry on.
> cordova emulate android
You have been opted out of telemetry. To change this, run: cordova telemetry on.
[14:00:28] lint finished in 2.60 s
ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_144
:wrapper
BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed
Subproject Path: CordovaLib
Downloading https://services.gradle.org/distributions/gradle-3.3-all.zip
之后报个错误 链接超时手动下载后
移动gradle-3.3-all.zip 到 C:\Users\Administrator\myApp\platforms\android\gradle 下
修改文件 C:\Users\Administrator\myApp\platforms\android\cordova\lib\builders\GradleBuilder.js
找到 gradle-3.3-all-zip
修改http ://xxx > ..
image.png
再次执行
C:\Users\Administrator\myApps>ionic cordova emulate android
[INFO] Running app-scripts build: --platform android --target cordova
[13:18:01] build dev started ...
[13:18:01] clean started ...
[13:18:01] clean finished in 6 ms
[13:18:01] copy started ...
[13:18:01] transpile started ...
[13:18:03] transpile finished in 2.60 s
[13:18:03] preprocess started ...
[13:18:03] deeplinks started ...
[13:18:03] deeplinks finished in 14 ms
[13:18:03] preprocess finished in 15 ms
[13:18:03] webpack started ...
[13:18:03] copy finished in 2.84 s
[13:18:11] webpack finished in 8.23 s
[13:18:11] sass started ...
[13:18:12] sass finished in 901 ms
[13:18:12] postprocess started ...
[13:18:12] removed unused font files
[13:18:12] postprocess finished in 14 ms
[13:18:12] lint started ...
[13:18:12] build dev finished in 11.82 s
> ionic cordova prepare android
> cordova prepare android
You have been opted out of telemetry. To change this, run: cordova telemetry on.
[13:18:15] lint finished in 2.51 s
> cordova emulate android
You have been opted out of telemetry. To change this, run: cordova telemetry on.
ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_144
Subproject Path: CordovaLib
The Task.leftShift(Closure) method has been deprecated and is scheduled to be re
moved in Gradle 5.0. Please use Task.doLast(Action) instead.
at build_1791eemw1dgas30ozsekse4x4.run(C:\Users\Administrator\myApps\pla
tforms\android\build.gradle:137)
The JavaCompile.setDependencyCacheDir() method has been deprecated and is schedu
led to be removed in Gradle 4.0.
Incremental java compilation is an incubating feature.
The TaskInputs.source(Object) method has been deprecated and is scheduled to be
removed in Gradle 4.0. Please use TaskInputs.file(Object).skipWhenEmpty() instea
d.
:preBuild UP-TO-DATE
:preDebugBuild UP-TO-DATE
:checkDebugManifest
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies
:CordovaLib:compileDebugAidl
UP-TO-DATE
:CordovaLib:compileDebugNdk
UP-TO-DATE
:CordovaLib:compileLint UP-TO-DATE
:CordovaLib:copyDebugLint
UP-TO-DATE
:CordovaLib:mergeDebugShaders
UP-TO-DATE
:CordovaLib:compileDebugShaders
UP-TO-DATE
:CordovaLib:generateDebugAssets
UP-TO-DATE
:CordovaLib:mergeDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugProguardFiles UP-TO-DATE
:CordovaLib:packageDebugRenderscript UP-TO-DATE
:CordovaLib:compileDebugRenderscript UP-TO-DATE
:CordovaLib:generateDebugResValues UP-TO-DATE
:CordovaLib:generateDebugResources UP-TO-DATE
:CordovaLib:packageDebugResources UP-TO-DATE
:CordovaLib:processDebugManifest UP-TO-DATE
:CordovaLib:generateDebugBuildConfig UP-TO-DATE
:CordovaLib:processDebugResources
UP-TO-DATE
:CordovaLib:generateDebugSources
UP-TO-DATE
:CordovaLib:incrementalDebugJavaCompilationSafeguard
UP-TO-DATE
:CordovaLib:compileDebugJavaWithJavac UP-TO-DATE
:CordovaLib:processDebugJavaRes UP-TO-DATE
:CordovaLib:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:CordovaLib:transformClassesAndResourcesWithSyncLibJarsForDebug
UP-TO-DATE
:CordovaLib:mergeDebugJniLibFolders UP-TO-DATE
:CordovaLib:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:CordovaLib:transformNative_libsWithSyncJniLibsForDebug UP-TO-DATE
:CordovaLib:bundleDebug UP-TO-DATE
:prepareOrgApacheCordovaCordovaLib623DebugLibrary UP-TO-DATE
:prepareDebugDependencies
:compileDebugAidl UP-TO-DATE
:compileDebugRenderscript UP-TO-DATE
:generateDebugBuildConfig
UP-TO-DATE
:generateDebugResValues UP-TO-DATE
:generateDebugResources UP-TO-DATE
:mergeDebugResources UP-TO-DATE
:processDebugManifest UP-TO-DATE
:processDebugResources UP-TO-DATE
:generateDebugSources UP-TO-DATE
:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:compileDebugJavaWithJavac UP-TO-DATE
:compileDebugNdk UP-TO-DATE
:compileDebugSources UP-TO-DATE
:mergeDebugShaders
UP-TO-DATE
:compileDebugShaders UP-TO-DATE
:generateDebugAssets UP-TO-DATE
:mergeDebugAssets UP-TO-DATE
:transformClassesWithDexForDebug UP-TO-DATE
:mergeDebugJniLibFolders UP-TO-DATE
:transformNative_libsWithMergeJniLibsForDebug
UP-TO-DATE
:processDebugJavaRes
UP-TO-DATE
:transformResourcesWithMergeJavaResForDebug
UP-TO-DATE
:validateSigningDebug
:packageDebug
UP-TO-DATE
:assembleDebug UP-TO-DATE
:cdvBuildDebug UP-TO-DATE
BUILD SUCCESSFUL
Total time: 1.773 secs
Built the following apk(s):
C:/Users/Administrator/myApps/platforms/android/build/outputs/apk/androi
d-debug.apk
ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_144
Skipping build...
Built the following apk(s):
C:/Users/Administrator/myApps/platforms/android/build/outputs/apk/androi
d-debug.apk
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Using apk: C:/Users/Administrator/myApps/platforms/android/build/outputs/apk/and
roid-debug.apk
Package name: io.ionic.starter
INSTALL SUCCESS
LAUNCH SUCCESS
[OK] Your app has been deployed.
Did you know you can live-reload changes from your app with --livereload?
C:\Users\Administrator\myApps>
C:\Users\Administrator\myApps>
avd中效果不好,我将apk 发送到手机上尽心查看
效果
Screenshot_2017-09-21-14-08-06-578_com.tencent.mo.png
Screenshot_2017-09-21-14-07-16-113_com.miui.home.png
Screenshot_2017-09-21-14-07-26-840_io.ionic.start.png
Screenshot_2017-09-21-14-07-32-997_io.ionic.start.png
Screenshot_2017-09-21-14-07-40-006_io.ionic.start.png