1.编译错误
ionic cordova run android -l -c
错误:Execution failed for task ':processDebugResources'.
com.android.ide.common.process.ProcessException: Failed to execute aapt
解决:木有解决,直接 remove 了 android 平台 重新添加
2.config.xml文件读取错误
执行命令:ionic cordova run android -l -c
出现错误:cp: copyFileSync: could not write to dest file (code=ENOENT):E:\work\app\cloudMall\platforms\android\res\xml\config.xml
E:\work\app\cloudMall1\platforms\android\res
发现目录缺少很多文件
解决:再次尝试remove android平台重新添加。
但是问题依然存在。
发现add 的是最新的7.0
重新制定版本添加android平台
ionic cordova platform add android@6.4.0
结果成功添加,res目录里面终于有文件了。
3.ionic build(run) err: your system to install the gradle wrapper. Please include gradle
(node:93136) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Could not find an installed version of Gradle either in Android Studio,
or on
in your path, or install Android Studio
(node:93136) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
解决办法:
1)去Gradle官网:https://gradle.org/install
2)下载Gradle:https://gradle.org/releases,我这里下载的是最新的3.5版本(gradle-3.5-bin.zip);
4)配置环境变量:系统变量--Path--编辑:
3.大坑,安装了android@6.4.0后,开发了一段时间后,期间安装了n个插件。当安装qqsdk做qq分享登录。时发现qqsdk支持版本 android@7.0.0以上版本。于是 rm android 、add android@7.0.0 出现错误。很多插件在之前安装的时候就是基于 android@6.4.0的。add android@7.0.0的时候出现插件安装错误。无法成功添加 android@7.0.0平台
---暂未解决
4.在mac中,使用模拟器运行没问题,打包成ipa后。安装到手机无法连接网络。
查找后发现是一个白名单插件问题。
1.答案1【https://segmentfault.com/q/1010000008502480/a-1020000008503060】
1.答案2【https://www.cnblogs.com/cabbage/p/ionic-request-404.html】
解决办法是:先卸载白名单插件,再安装一遍(如果此问题没有读到解决,请查看下面第6坑)
cordova plugin remove cordova-plugin-whitelist
cordova plugin add cordova-plugin-whitelist
//注:如果之前没有安装此插件就输入第二句就可以了
5.android编译打包时报错Error: "download_complete_title" is not translated in "es" (Spanish), "hu" ....
`
Explanation for issues of type "MissingTranslation":
If an application has more than one locale, then all the strings declared
in one language should also be translated in all other languages.
If the string should not be translated, you can add the attribute
translatable="false" on the <string> element, or you can define all your
non-translatable strings in a resource file called donottranslate.xml. Or,
you can ignore the issue with a tools:ignore="MissingTranslation"
attribute.
By default this detector allows regions of a language to just provide a
subset of the strings and fall back to the standard language strings. You
can require all regions to provide a full translation by setting the
environment variable ANDROID_LINT_COMPLETE_REGIONS.
You can tell lint (and other tools) which language is the default language
in your res/values/ folder by specifying tools:locale="languageCode" for
the root <resources> element in your resource file. (The tools prefix
refers to the namespace declaration http://schemas.android.com/tools.)
`
解决:
文件1...项目\platforms\android\res\values\appupdate_strings.xml
文件2...项目\platforms\android\res\values\strings.xml
resources 中都以下添加属性代码
<resources tools:ignore="MissingTranslation" xmlns:tools="http://schemas.android.com/tools" xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"></resources>
6.ios打包安装后无法访问http请求出现错误,无法获取数据
请求返回如下:
{"_body":{"isTrusted":true},"status":0,"ok":false,"statusText":"","headers":{},"type":3,"url":null}
卡在这很久,开始以为是应苹果官方要求,需要使用 https 安全访问。也在xcode里面配置了
NSAppTransportSecurity
,然而并没有什么用。研究发现。在浏览器测试的时候,突然发现跨域报的错误和这个一模一样。发现是跨域问题 wkwebview 在ios会存在跨域问题。
最好的解决办法当然是后台配置容许跨域访问。
相对于我的项目,我的解决办法是删除cordova-plugin-ionic-webview
插件:
cordova plugin remove cordova-plugin-ionic-webview
7.使用refresher进行页面下拉刷新,如果页面有顶部固定区域(position: fixed;)如筛选栏。下拉时会导致界面布局打乱顶部区域位置 top 会往下跑。
解决办法发现是因为 '.scroll-content'容器 style transform 被设置为 'rotateZ(0)'。使用定时器将其复原为 'initial'即可,并在ion-content里添加fullscreen
属性:
<ion-content fullscreen>
<ion-refresher (ionRefresh)="doRefresh($event)">
<ion-refresher-content></ion-refresher-content>
</ion-refresher>
</ion-content>
//-------------------------------------------------------------------------------------------------------------
//补充bug修复----在执行 complete() 结束下拉刷新时执行以下定时器。
/*恢复上拉刷新状态*/
setTimeout(() => {
/*修复下拉刷新导致页面fiexd滚动问题*/
var _scroll_contents = document.getElementsByClassName("scroll-content");
for(var i = 0; i < _scroll_contents.length; i++) {
console.log(_scroll_contents[i]);
_scroll_contents[i].style.transform = "initial";
}
}, 500);
refresher.complete();
2018年4月19日 - 针对此问题提供解决方案2:
使用FabContainer
:https://ionicframework.com/docs/api/components/fab/FabContainer/
官网描述:
<ion-fab> is not a FAB button by itself but a container that assist the fab button (<button ion-fab>) allowing it to be placed in fixed position that does not scroll with the content. It is also used to implement "material design speed dial", ie. a FAB buttons displays a small lists of related actions when clicked.
大致意思就是,不会随着页面滚动的固定位置容器。
注意:虽然官网上解释说:‘本身不是一个FAB按钮,而是一个容器’,但是这个容器,事实上他还必须要放入一个按钮 <button ion-fab mini hidden></button>
,不然会报错误:
Error:fab-container.js:101 FAB container needs a main <button ion-fab>