当前位置:   article > 正文

Angular、ionic、Cordova的关系介绍与打包_angular与ionic h5打包

angular与ionic h5打包

一、关系介绍

Angular:是一个前端JS框架,类似于JQuery,BootStrap,Three.js等。

ionic :是开源的H5移动App开发框架,是Angular的衍生物,利用Angular实现很多移动端的组件。

Cordova:在项目中,Cordova负责将前端页面包装成原生页面,作为一个桥梁负责前端页面与原生应用的通信。另外,前端页 面没有调用设备的能力,这时就需要与原生应用通信来,通过cordova插件调用设备,例如相机,文件等。

二、打包

    1.常用命令

            ionic serve

            ionic cordova build android    #打包

            cordova platform rm android    #移除项目中的android环境

            cordova platform add android@6.3.0    #添加安装环境,@xxx是安卓版本号

            cordova platforms list    #列出项目环境

            ionic cordova plugin list    #列出项目中安装的插件

            cordova plugin remove  XXX    #卸载插件

            cordova plugin add XXX    #安装插件

       2.项目中的环境配置

               cordova platforms list


可以看出,项目中的安卓环境是android6.3.0

cordova plugins list


项目中所安装的插件,其中最重要的是cordova-plugin-camera,cordova-plugin-file,cordova-plugin-transfer这三个插件,是拍照,以及上传图片功能所用到的插件,在后面详细介绍

3.上传图片插件安装

不管是从相册中选择图片上传,还是拍照上传。我们都需要如下先安装如下三个插件:Camera(相机)、file(文件访问操作)、fileTransfer(文件传输)。

cordova plugin add cordova-plugin-camera
cordova plugin add cordova-plugin-file
cordova plugin add cordova-plugin-file-transfer

在cordova插件中有一个插件:cordova-

-image-picker,在安卓中选择图片上传会出现闪退现象,解决方法很简单

cordova plugin remove com.synconset.imagepicker #删除这个插件

npm install git      #npm安装git,详情见http://blog.csdn.net/yiifaa/article/details/53784427

cordova plugin add https://github.com/Findiglay/cordova-imagePicker.git    #从git上安装一个修复过的plugin

上传图片搞定。。。

有一段时间在ionic cordova build android打包的过程中(安装环境是6.3.0),会报如下错误

  1. BUILD FAILED
  2. Total time: 19.142 secs
  3. ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:ttcIndex
  4. FAILURE: Build failed with an exception.
  5. * What went wrong:
  6. Execution failed for task ':processDebugResources'.
  7. > com.android.ide.common.process.ProcessException: Failed to execute aapt
  8. * Try:
  9. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  10. Error: cmd: Command failed with exit code 1 Error output:
  11. ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontVariationSettings
  12. ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:ttcIndex
  13. FAILURE: Build failed with an exception.
  14. * What went wrong:
  15. Execution failed for task ':processDebugResources'.
  16. > com.android.ide.common.process.ProcessException: Failed to execute aapt
  17. * Try:
  18. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  19. [ERROR] An error occurred while running cordova build android (exit code 1).

解决办法是在platforms/android/build.gradle中顶级节点加入

configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:27.1.0'
    }
}


声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/空白诗007/article/detail/748964
推荐阅读
相关标签
  

闽ICP备14008679号