我需要帮助,我在我的智慧在这里结束。 我开发了一个应用程序与durandaljs和我一直在浏览器上做我的测试,到目前为止它的作品就像一个梦!然后我尝试将应用程序部署到Android设备,所有地狱都打破了!部署Durandaljs/Phonegap应用程序到Android
我按照指示here和here来使用节点优化我的构建与Weyland。我的应用程序文件夹中有一个main-built.js文件,并且包含一个包含应用程序和lib文件夹中的所有内容的构建文件夹(eek !!!)。所以第一个问题,我该怎么复制到我的phonegap android www文件夹;构建的内容或我最初的应用程序的内容?
该指南说构建包括一个自定义版本的杏仁,所以我不需要在我的应用程序中加载requirejs(耶!),我只需要将requirejs脚本标记更改为指向主构建(哪一个./build/app/中的或者./app中的那个)。
所以我使用了一个在我最初的应用程序,现在我有我的index.html只有两个脚本引用
<script type="text/javascript" src="phonegap.js"></script>
<script src="./app/main-built.js"></script>
返回跟踪了一下,在我main.js;我一直在考虑如何确保应用程序在deviceready被触发和dom加载之后才启动。我看到这个youtube video,我把从人的代码提示所以现在看起来优化我main.js之前部分这样
requirejs.config({
paths: {
'text': '../lib/require/text',
'async': '../lib/require/async',
'domReady': '../lib/require/domReady',
'durandal': '../lib/durandal/js',
'plugins': '../lib/durandal/js/plugins',
'transitions': '../lib/durandal/js/transitions',
'knockout': '../lib/knockout/knockout-2.3.0',
'bootstrap': '../lib/bootstrap/js/bootstrap',
'jquery': '../lib/jquery/jquery-1.9.1',
'jpanelmenu': '../lib/jpanelMenu/jquery.jpanelmenu.min'
},
shim: {
'bootstrap': {
deps: ['jquery'],
exports: 'jQuery'
}
}
});
define(['domReady', 'durandal/system', 'durandal/app', 'durandal/viewLocator', 'scripts/dealtag'], function (domReady, system, app, viewLocator, dealtag) {
domReady(function() {
var useragent = navigator.userAgent.toLowerCase();
if (useragent.match(/android/) || useragent.match(/iphone/) || useragent.match(/ipad/) || useragent.match('ios')) {
document.addEventListener('deviceready', onDeviceReady, false);
}
else {
onDeviceReady('desktop');
}
});
function onDeviceReady(desktop) {
if (desktop !== 'desktop')
cordova.exec(null, null, 'SplashScreen', 'hide', []);
app.title = 'My App';
app.configurePlugins({
router: true,
dialog: true,
widget: true
});
app.start().then(function() {
//Replace 'viewmodels' in the moduleId with 'views' to locate the view.
//Look for partial views in a 'views' folder in the root.
viewLocator.useConvention();
....my own initialization code
});
}
});
所以回优化后,我复制生成的内容+我的css文件夹,其没有包含在优化到www文件夹中,运行phonegap local build android;然后我将其部署到我的Android设备。应用程序的第一页(注册页面)加载正常,在logcat中,我可以看到很多与浏览器控制台中可以看到的相同的东西,包括我自己的一些console.log检查点。然而,当我点击一个链接到任何其他网页,我看到的是一个白色的屏幕设备上,并在无休止的错误在logcat的
有没有人有任何想法,我做错了以下使用durandaljs的人似乎正在为Android开发人员。预先感谢您提供的任何帮助。
您是否尝试将非构建应用程序意味着像桌面模式一样的原始状态复制到assets文件夹中?听起来像一些引用缺失。你在哪里调用addRow?该对象是否定义了? – zewa666
你好zewa,我至少不会说我知道的addrow。是的,我试图用非优化文件和requirejs等来部署应用程序,这只是给我一个在我没有创建的文件中引发的requirejs脚本错误,并且不是描述问题的源头 –
那么如果那不是帮助唯一的区别应该与科尔多瓦。你有没有试过另一个版本? – zewa666