在appcan 中 使用了 插件的代码的调试 很令人讨厌,只能使用在线打包 进行真机调试。
另外,目前APPCAN真机调试时,输出日志到IDE是比较臭的。。。
而且在在线打包时一定要注意 使用的插件的版本 是否和 采用的操作系统的版本兼容(很操的一个,其很多的不向下兼容)。
具体步骤如下:
前提要保证IDE所在电脑的IP段与手机的IP段是一致的。
1.首先在config.xml里配置允许真机调试,设置调试服务器地址,以及勾上实时同步
2.在线打包时勾上uexLog插件。注意,这个插件只在项目没上线时用着,正式发布时,线上打包回自动把这个插件去掉。
3.写个日志输出方法(uexLog这插件只支持文本输出)
Date.prototype.Format = function(str) {
var o = {
"M+" : this.getMonth() + 1, //月份
"d+" : this.getDate(), //日
"h+" : this.getHours(), //小时
"m+" : this.getMinutes(), //分
"s+" : this.getSeconds(), //秒
"q+" : Math.floor((this.getMonth() + 3) / 3), //季度
"S" : this.getMilliseconds() //毫秒
};
if (/(y+)/.test(str))
str= str.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(str))
str= str.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return str;
};
var isLogEnable = true; //日志输出开关
function Logs(str) {
if (isLogEnable) {
var dateStr = (new Date().Format("yyyy-MM-dd hh:mm:ss"));
str = dateStr + " " + uexWidgetOne.platformName + "-->" + str;
if (uexLog) {
appcan.logs(str);
} else {
console.log(str);
}
}
}
4.最后要启动一下真机同步调试服务。
PS:注意电脑防火墙,,有可能导致日志无法发送。。建议,调试时关闭防火墙
2016-04-19 10:12:33 iOS-->closeWin-->groupChatRoom
2016-04-19 10:12:33 iOS-->closeWin-->groupChatInfo
2016-04-19 10:12:34 android-->uexEasemob.onGroupDestroy:{"groupId":"1460690937481","groupName":"我的测试�?"}
2016-04-19 10:12:34 android-->removeFriendHtml:1460690937481,1
2016-04-19 10:12:34 android-->removeLastMsgId:1460690937481