ionic 创建程序及打包环境配置

准备工具
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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 206,214评论 6 481
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 88,307评论 2 382
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 152,543评论 0 341
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 55,221评论 1 279
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 64,224评论 5 371
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,007评论 1 284
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,313评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,956评论 0 259
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 43,441评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,925评论 2 323
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,018评论 1 333
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,685评论 4 322
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,234评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,240评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,464评论 1 261
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,467评论 2 352
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,762评论 2 345

推荐阅读更多精彩内容