ionic 入坑体验

# 为npm设置代理
$ npm config set proxy http://server:port
$ npm config set https-proxy http://server:port
#卸载ionic
sudo npm uninstall -g ionic
#安装ionic
sudo npm install -g ionic
#创建项目
ionic start myApp tabs
--> 无尽漫长的等待 <--
ionic 入坑体验_第1张图片
ionic start myApp tabs.png

如果卡死在红框处,看

#设置使用淘宝镜像,至关重要 ***
npm config set registry https://registry.npm.taobao.org
#查看是否设置成功,成功会返回一堆打印
npm info underscore
#启动页面
ionic serve --lab

--> 千呼万唤始出来,得意的笑 <---


ionic 入坑体验_第2张图片
ionic.png

Android客户端运行

$ cordova create hello com.example.hello HelloWorld
$ cd HelloWorld
$ cordova platform add android
$ cordova prepare
$ cordova build android

  ANDROID_HOME=/Users/yu/Library/Android/sdk
  JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
  Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK.
  Looked here: /Users/yu/Library/Android/sdk/tools/templates/gradle/wrapper

# 解决方法,AndroidStudio安装目录下的Contents/plugins/android/lib/templates拷贝到${ANDROID_HOME}/tools下 :

$ cp -r /Applications/Android\ Studio.app/Contents/plugins/android/lib/templates /Library/Android/sdk/tools

运行cordova build android后 出现如下提示:

cordova build android

继续

$cordova build android
  ANDROID_HOME=/Users/yu/Library/Android/sdk
  JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
  Subproject Path: CordovaLib
  Error: spawn EACCES
#Mac,说明没有权限,需要添加下权限,执行以下命令
$ chmod a+x {ANDROID_HOME}/tools/templates/gradle/wrapper/gradlew

goon

$ cordova build android
  ANDROID_HOME=/Users/yu/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
Subproject Path: CordovaLib
Downloading https://services.gradle.org/distributions/gradle-2.14.1-all.zip
...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Unzipping /Users/yu/.gradle/wrapper/dists/gradle-2.14.1-all/8bnwg5hd3w55iofp58khbp6yv/gradle-2.14.1-all.zip to /Users/yu/.gradle/wrapper/dists/gradle-2.14.1-all/8bnwg5hd3w55iofp58khbp6yv
Set executable permissions for: /Users/yu/.gradle/wrapper/dists/gradle-2.14.1-all/8bnwg5hd3w55iofp58khbp6yv/gradle-2.14.1/bin/gradle
Starting a new Gradle Daemon for this build (subsequent builds will be faster).
Download https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.pom
Download https://jcenter.bintray.com/com/android/tools/build/gradle-core/2.2.1/gradle-core-2.2.1.pom
Download https://jcenter.bintray.com/com/android/tools/build/builder/2.2.1/builder-2.2.1.pom
Download https://jcenter.bintray.com/com/android/tools/lint/lint/25.2.1/lint-25.2.1.pom
Download https://jcenter.bintray.com/com/android/tools/build/gradle-api/2.2.1/gradle-api-2.2.1.pom
Download https://jcenter.bintray.com/com/android/databinding/compilerCommon/2.2.1/compilerCommon-2.2.1.pom
Download https://repo1.maven.org/maven2/org/ow2/asm/asm/5.0.4/asm-5.0.4.pom
Download https://repo1.maven.org/maven2/org/ow2/asm/asm-parent/5.0.4/asm-parent-5.0.4.pom
Download https://repo1.maven.org/maven2/org/ow2/asm/asm-commons/5.0.4/asm-commons-5.0.4.pom
Download https://repo1.maven.org/maven2/org/jacoco/org.jacoco.core/0.7.5.201505241946/org.jacoco.core-0.7.5.201505241946.pom
Download https://repo1.maven.org/maven2/org/jacoco/org.jacoco.build/0.7.5.201505241946/org.jacoco.build-0.7.5.201505241946.pom
Download https://repo1.maven.org/maven2/org/jacoco/org.jacoco.report/0.7.5.201505241946/org.jacoco.report-0.7.5.201505241946.pom
Download https://repo1.maven.org/maven2/net/sf/jopt-simple/jopt-simple/4.9/jopt-simple-4.9.pom
Download https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/2.5.0/protobuf-java-2.5.0.pom
Download https://repo1.maven.org/maven2/com/google/google/1/google-1.pom
Download https://jcenter.bintray.com/com/android/tools/build/builder-model/2.2.1/builder-model-2.2.1.pom
Download https://jcenter.bintray.com/com/android/tools/build/builder-test-api/2.2.1/builder-test-api-2.2.1.pom
Download https://jcenter.bintray.com/com/android/tools/sdklib/25.2.1/sdklib-25.2.1.pom
Download https://jcenter.bintray.com/com/android/tools/sdk-common/25.2.1/sdk-common-25.2.1.pom
Download https://jcenter.bintray.com/com/android/tools/common/25.2.1/common-25.2.1.pom
Download https://jcenter.bintray.com/com/android/tools/build/manifest-merger/25.2.1/manifest-merger-25.2.1.pom
Download https://jcenter.bintray.com/com/android/tools/ddms/ddmlib/25.2.1/ddmlib-25.2.1.pom
Download https://repo1.maven.org/maven2/com/android/tools/jack/jack-api/0.11.0/jack-api-0.11.0.pom
Download https://jcenter.bintray.com/com/android/tools/analytics-library/protos/25.2.1/protos-25.2.1.pom
Download https://jcenter.bintray.com/com/android/tools/analytics-library/shared/25.2.1/shared-25.2.1.pom
Download https://jcenter.bintray.com/com/android/tools/analytics-library/tracker/25.2.1/tracker-25.2.1.pom
Download https://repo1.maven.org/maven2/org/ow2/asm/asm-tree/5.0.4/asm-tree-5.0.4.pom
Download https://jcenter.bintray.com/com/android/tools/lint/lint-checks/25.2.1/lint-checks-25.2.1.pom
Download https://repo1.maven.org/maven2/org/eclipse/jdt/core/compiler/ecj/4.5.1/ecj-4.5.1.pom
Download https://jcenter.bintray.com/com/android/databinding/baseLibrary/2.2.1/baseLibrary-2.2.1.pom
Download https://repo1.maven.org/maven2/org/antlr/antlr4/4.5.3/antlr4-4.5.3.pom
Download https://repo1.maven.org/maven2/org/antlr/antlr4-master/4.5.3/antlr4-master-4.5.3.pom
Download https://repo1.maven.org/maven2/com/android/tools/annotations/24.5.0/annotations-24.5.0.pom
Download https://jcenter.bintray.com/com/android/tools/layoutlib/layoutlib-api/25.2.1/layoutlib-api-25.2.1.pom
Download https://jcenter.bintray.com/com/android/tools/dvlib/25.2.1/dvlib-25.2.1.pom
Download https://jcenter.bintray.com/com/android/tools/repository/25.2.1/repository-25.2.1.pom
Download https://jcenter.bintray.com/com/android/tools/lint/lint-api/25.2.1/lint-api-25.2.1.pom
Download https://repo1.maven.org/maven2/org/ow2/asm/asm-analysis/5.0.4/asm-analysis-5.0.4.pom
Download https://repo1.maven.org/maven2/com/google/jimfs/jimfs/1.1/jimfs-1.1.pom
Download https://repo1.maven.org/maven2/com/google/jimfs/jimfs-parent/1.1/jimfs-parent-1.1.pom
Download https://jcenter.bintray.com/com/android/tools/external/com-intellij/uast/145.597.3/uast-145.597.3.pom
Download https://jcenter.bintray.com/com/android/tools/annotations/25.2.1/annotations-25.2.1.pom
Download https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.jar
Download https://jcenter.bintray.com/com/android/tools/build/gradle-core/2.2.1/gradle-core-2.2.1.jar
Download https://jcenter.bintray.com/com/android/tools/build/builder/2.2.1/builder-2.2.1.jar
Download https://jcenter.bintray.com/com/android/tools/lint/lint/25.2.1/lint-25.2.1.jar
Download https://jcenter.bintray.com/com/android/tools/build/gradle-api/2.2.1/gradle-api-2.2.1.jar
Download https://jcenter.bintray.com/com/android/databinding/compilerCommon/2.2.1/compilerCommon-2.2.1.jar
Download https://repo1.maven.org/maven2/org/ow2/asm/asm/5.0.4/asm-5.0.4.jar
Download https://repo1.maven.org/maven2/org/ow2/asm/asm-commons/5.0.4/asm-commons-5.0.4.jar
Download https://repo1.maven.org/maven2/org/jacoco/org.jacoco.core/0.7.5.201505241946/org.jacoco.core-0.7.5.201505241946.jar
Download https://repo1.maven.org/maven2/org/jacoco/org.jacoco.report/0.7.5.201505241946/org.jacoco.report-0.7.5.201505241946.jar
Download https://repo1.maven.org/maven2/net/sf/jopt-simple/jopt-simple/4.9/jopt-simple-4.9.jar
Download https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/2.5.0/protobuf-java-2.5.0.jar
Download https://jcenter.bintray.com/com/android/tools/build/builder-model/2.2.1/builder-model-2.2.1.jar
Download https://jcenter.bintray.com/com/android/tools/build/builder-test-api/2.2.1/builder-test-api-2.2.1.jar
Download https://jcenter.bintray.com/com/android/tools/sdklib/25.2.1/sdklib-25.2.1.jar
Download https://jcenter.bintray.com/com/android/tools/sdk-common/25.2.1/sdk-common-25.2.1.jar
Download https://jcenter.bintray.com/com/android/tools/common/25.2.1/common-25.2.1.jar
Download https://jcenter.bintray.com/com/android/tools/build/manifest-merger/25.2.1/manifest-merger-25.2.1.jar
Download https://jcenter.bintray.com/com/android/tools/ddms/ddmlib/25.2.1/ddmlib-25.2.1.jar
Download https://repo1.maven.org/maven2/com/android/tools/jack/jack-api/0.11.0/jack-api-0.11.0.jar
Download https://jcenter.bintray.com/com/android/tools/analytics-library/protos/25.2.1/protos-25.2.1.jar
Download https://jcenter.bintray.com/com/android/tools/analytics-library/shared/25.2.1/shared-25.2.1.jar
Download https://jcenter.bintray.com/com/android/tools/analytics-library/tracker/25.2.1/tracker-25.2.1.jar
Download https://repo1.maven.org/maven2/org/ow2/asm/asm-tree/5.0.4/asm-tree-5.0.4.jar
Download https://jcenter.bintray.com/com/android/tools/lint/lint-checks/25.2.1/lint-checks-25.2.1.jar
Download https://repo1.maven.org/maven2/org/eclipse/jdt/core/compiler/ecj/4.5.1/ecj-4.5.1.jar
Download https://jcenter.bintray.com/com/android/databinding/baseLibrary/2.2.1/baseLibrary-2.2.1.jar
Download https://repo1.maven.org/maven2/org/antlr/antlr4/4.5.3/antlr4-4.5.3.jar
Download https://jcenter.bintray.com/com/android/tools/layoutlib/layoutlib-api/25.2.1/layoutlib-api-25.2.1.jar
Download https://jcenter.bintray.com/com/android/tools/dvlib/25.2.1/dvlib-25.2.1.jar
Download https://jcenter.bintray.com/com/android/tools/repository/25.2.1/repository-25.2.1.jar
Download https://jcenter.bintray.com/com/android/tools/lint/lint-api/25.2.1/lint-api-25.2.1.jar
Download https://repo1.maven.org/maven2/org/ow2/asm/asm-analysis/5.0.4/asm-analysis-5.0.4.jar
Download https://repo1.maven.org/maven2/com/google/jimfs/jimfs/1.1/jimfs-1.1.jar
Download https://jcenter.bintray.com/com/android/tools/external/com-intellij/uast/145.597.3/uast-145.597.3.jar
Download https://jcenter.bintray.com/com/android/tools/annotations/25.2.1/annotations-25.2.1.jar
Incremental java compilation is an incubating feature.
: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
:CordovaLib:compileDebugNdk UP-TO-DATE
:CordovaLib:compileLint
:CordovaLib:copyDebugLint UP-TO-DATE
:CordovaLib:mergeDebugShaders
:CordovaLib:compileDebugShaders
:CordovaLib:generateDebugAssets
:CordovaLib:mergeDebugAssets
:CordovaLib:mergeDebugProguardFiles
:CordovaLib:packageDebugRenderscript UP-TO-DATE
:CordovaLib:compileDebugRenderscript
:CordovaLib:generateDebugResValues
:CordovaLib:generateDebugResources
:CordovaLib:packageDebugResources
:CordovaLib:processDebugManifest
:CordovaLib:generateDebugBuildConfig
:CordovaLib:processDebugResources
:CordovaLib:generateDebugSources
:CordovaLib:incrementalDebugJavaCompilationSafeguard
:CordovaLib:compileDebugJavaWithJavac
:CordovaLib:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
注: 某些输入文件使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
:CordovaLib:processDebugJavaRes UP-TO-DATE
:CordovaLib:transformResourcesWithMergeJavaResForDebug
:CordovaLib:transformClassesAndResourcesWithSyncLibJarsForDebug
:CordovaLib:mergeDebugJniLibFolders
:CordovaLib:transformNative_libsWithMergeJniLibsForDebug
:CordovaLib:transformNative_libsWithSyncJniLibsForDebug
:CordovaLib:bundleDebug
:prepareAndroidCordovaLibUnspecifiedDebugLibrary
:prepareDebugDependencies
:compileDebugAidl
:compileDebugRenderscript
:generateDebugBuildConfig
:generateDebugResValues
:generateDebugResources
:mergeDebugResources
:processDebugManifest
:processDebugResources
:generateDebugSources
:incrementalDebugJavaCompilationSafeguard
:compileDebugJavaWithJavac
:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
:compileDebugNdk UP-TO-DATE
:compileDebugSources
:mergeDebugShaders
:compileDebugShaders
:generateDebugAssets
:mergeDebugAssets
:transformClassesWithDexForDebug
:mergeDebugJniLibFolders
:transformNative_libsWithMergeJniLibsForDebug
:processDebugJavaRes UP-TO-DATE
:transformResourcesWithMergeJavaResForDebug
:validateSigningDebug
:packageDebug
:assembleDebug
:cdvBuildDebug

BUILD SUCCESSFUL

Total time: 22 mins 51.19 secs
Built the following apk(s):
    /Users/yu/apps/crash/myApp/hello/platforms/android/build/outputs/apk/android-debug.apk


$ adb install /Users/yu/apps/crash/myApp/hello/platforms/android/build/outputs/apk/android-debug.apk
  /Users/yu/apps/crash/myApp/hello/platforms/android/build/outputs/apk/android-debug.apk: 1 file pushed. 1.9 MB/s (1835957 bytes in 0.934s)
    pkg: /data/local/tmp/android-debug.apk
Success


ionic 入坑体验_第3张图片
image.png

无尽的长路伴着我

参考:
http://www.cnblogs.com/huang0925/archive/2013/05/17/3083207.html
https://ionicframework.com/framework
http://blog.csdn.net/jiana227/article/details/50730290
http://blog.csdn.net/zoe_wang_ing/article/details/51679210
http://www.cnblogs.com/sloong/p/5204727.html
http://www.jianshu.com/p/3a8d7e23ed79
http://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html
http://www.jianshu.com/p/5d925413c79f

你可能感兴趣的:(ionic 入坑体验)