博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Angular、ionic、Cordova的关系介绍与打包
阅读量:3557 次
发布时间:2019-05-20

本文共 2474 字,大约阅读时间需要 8 分钟。

一、关系介绍

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),会报如下错误

BUILD FAILED Total time: 19.142 secsERROR: In 
FontFamilyFont, unable to find attribute android:ttcIndex FAILURE: Build failed with an exception. * What went wrong:Execution failed for task ':processDebugResources'.> com.android.ide.common.process.ProcessException: Failed to execute aapt * Try:Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.Error: cmd: Command failed with exit code 1 Error output:ERROR: In
FontFamilyFont, unable to find attribute android:fontVariationSettingsERROR: In
FontFamilyFont, unable to find attribute android:ttcIndex FAILURE: Build failed with an exception. * What went wrong:Execution failed for task ':processDebugResources'.> com.android.ide.common.process.ProcessException: Failed to execute aapt * Try:Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. [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'    }}

你可能感兴趣的文章
N1 技术心得 2019-6-26
查看>>
N1-环境配置
查看>>
N2-审计方法与步骤
查看>>
N3-常见的INI配置
查看>>
代码审计 N4 常见危险函数和特殊函数(一)
查看>>
MySQL笔记
查看>>
计算机运算方法之(原码 补码 反码 移码)
查看>>
计算机组成原理之(二进制与十进制互相转换,数的定点表示与浮点数表示)例题:设浮点数字长16位,其中阶码5位(含有1位阶符),尾数11位(含有1位数符)
查看>>
冒泡排序及其优化
查看>>
选择排序(java代码实现)
查看>>
插入排序
查看>>
哈夫曼树java代码实现
查看>>
快速排序
查看>>
vue路由高亮的两种方式
查看>>
vue router 报错: Uncaught (in promise) NavigationDuplicated {_name:""NavigationDuplicated"... 的解决方法
查看>>
vue跳转页面的两种方式
查看>>
存储器题目解析(持续更新中....)
查看>>
存储器知识要点
查看>>
Cache模拟器的实现
查看>>
实验2:MIPS指令系统和MIPS体系结构
查看>>