0

使用 CLI 构建时,一切似乎都正常,直到我查看控制台进行预览,然后我看到有一些丢失的文件。这是控制台输出:

安卓:

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.
GET http://localhost:10080/MyProject/apps/services/preview/MyApp/android/1.0/default/cordova/cordovasim.js 404 (Not Found)_mbs_cordova_sim_load_js @ cordova.js:21(anonymous function) @ cordova.js:53
worklight.js:5138 Uncaught Exception: Uncaught ReferenceError: cordova is not defined at (compiled_code):16156WL.Logger.__log @ worklight.js:5138WL.Logger.$.each.PUBLIC_API.(anonymous function) @ worklight.js:5520WL.Logger.window.onerror @ worklight.js:5478
worklight.js:16156 Uncaught ReferenceError: cordova is not defined(anonymous function) @ worklight.js:16156
worklight.js:5134 Initialization option 'connectOnStartup' is deprecated. Use WL.Client.connect() to connect to the IBM MobileFirst Platform Server.
worklight.js:5134 wlclient init started
dependencies.js:10 WL not defined ReferenceError: cordova is not defined
    at klass.WL.BusyIndicator.WLJSX.Class.create.show (http://localhost:10080/MyProject/apps/services/preview/MyApp/android/1.0/default/worklight/worklight.js:12157:6)
    at __showBusy (http://localhost:10080/MyProject/apps/services/preview/MyApp/android/1.0/default/worklight/worklight.js:7345:18)
    at onEnvInit (http://localhost:10080/MyProject/apps/services/preview/MyApp/android/1.0/default/worklight/worklight.js:7660:14)
    at init (http://localhost:10080/MyProject/apps/services/preview/MyApp/android/1.0/default/worklight/worklight.js:8128:4)
    at http://localhost:10080/MyProject/apps/services/preview/MyApp/android/1.0/default/assets/js/dependencies.js:10:990(anonymous function) @ dependencies.js:10
angular-libs.js:8 [10:40:49]MyApp.home.controller :: [INFO] Welcome to MyApp

苹果手机:

    http://localhost:10080/MyProject/apps/services/preview/MyApp/iphone/1.0/default/worklight/cordova.js Failed to load resource: the server responded with a status of 404 (Not Found)_mbs_cordova_sim_load_js @ cordova.js:21
    cordova.js:26 Uncaught ReferenceError: cordova is not defined
    worklight.js:5134 Initialization option 'connectOnStartup' is deprecated. Use WL.Client.connect() to connect to the IBM MobileFirst Platform Server.
    worklight.js:5134 wlclient init started
    worklight.js:5134 Request [/MyProject/apps/services/api/MyApp/iphone/init]
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134
    http://localhost:10080/MyProject/apps/services/api/MyApp/iphone/init Failed to load resource: the server responded with a status of 401 (Unauthorized)
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134
    worklight.js:5134 Request [/MyProject/apps/services/api/MyApp/iphone/init]
    angular-libs.js:8 [10:38:54]MyApp.home.controller :: [INFO] Welcome to MyApp
    http://localhost:10080/favicon.ico Failed to load resource: the server responded with a status of 404 (Not Found)
    worklight.js:5134 response [/MyProject/apps/services/api/MyApp/iphone/init] success: /*-secure-
    {"userPrefs":{},"WL-Authentication-Success":{"wl_directUpdateRealm":{"userId":"null","attributes":{},"isUserAuthenticated":1,"displayName":"null","deviceId":"null"},"wl_remoteDisableRealm":{"userId":"null","attributes":{},"isUserAuthenticated":1,"displayName":"null","deviceId":"null"},"wl_antiXSRFRealm":{"userId":"1n4ulchkhlmjgom2cmafk8qvpm","attributes":{},"isUserAuthenticated":1,"displayName":"1n4ulchkhlmjgom2cmafk8qvpm","deviceId":"1n4ulchkhlmjgom2cmafk8qvpm"},"wl_deviceNoProvisioningRealm":{"userId":"previewDummyId","attributes":{"mobileClientData":"com.worklight.core.auth.ext.MobileClientData@ff55f"},"isUserAuthenticated":1,"displayName":"previewDummyId","deviceId":"previewDummyId"},"wl_anonymousUserRealm":{"userId":"6ba49e22-f899-4b14-ae72-fc4fde9100de","attributes":{},"isUserAuthenticated":1,"displayName":"6ba49e22-f899-4b14-ae72-fc4fde9100de","deviceId":"6ba49e22-f899-4b14-ae72-fc4fde9100de"}},"gadgetProps":{"ENVIRONMENT":"iphone"},"userInfo":{"SubscribeServlet":{"userId":null,"attributes":{},"isUserAuthenticated":0,"displayName":null,"deviceId":null},"wl_directUpdateRealm":{"userId":"null","attributes":{},"isUserAuthenticated":1,"displayName":"null","deviceId":"null"},"wl_authenticityRealm":{"userId":null,"attributes":{},"isUserAuthenticated":0,"displayName":null,"deviceId":null},"SampleAppRealm":{"userId":null,"attributes":{},"isUserAuthenticated":0,"displayName":null,"deviceId":null},"wl_remoteDisableRealm":{"userId":"null","attributes":{},"isUserAuthenticated":1,"displayName":"null","deviceId":"null"},"wl_antiXSRFRealm":{"userId":"1n4ulchkhlmjgom2cmafk8qvpm","attributes":{},"isUserAuthenticated":1,"displayName":"1n4ulchkhlmjgom2cmafk8qvpm","deviceId":"1n4ulchkhlmjgom2cmafk8qvpm"},"wl_deviceAutoProvisioningRealm":{"userId":null,"attributes":{},"isUserAuthenticated":0,"displayName":null,"deviceId":null},"wl_deviceNoProvisioningRealm":{"userId":"previewDummyId","attributes":{"mobileClientData":"com.worklight.core.auth.ext.MobileClientData@ff55f"},"isUserAuthenticated":1,"displayName":"previewDummyId","deviceId":"previewDummyId"},"myserver":{"userId":"6ba49e22-f899-4b14-ae72-fc4fde9100de","attributes":{},"isUserAuthenticated":1,"displayName":"6ba49e22-f899-4b14-ae72-fc4fde9100de","deviceId":"6ba49e22-f899-4b14-ae72-fc4fde9100de"},"wl_anonymousUserRealm":{"userId":"6ba49e22-f899-4b14-ae72-fc4fde9100de","attributes":{},"isUserAuthenticated":1,"displayName":"6ba49e22-f899-4b14-ae72-fc4fde9100de","deviceId":"6ba49e22-f899-4b14-ae72-fc4fde9100de"}}}*/
    worklight.js:5788 No matching configurations found from the server. Defaulting to local configuration
    worklight.js:5134 wlclient connect success
    worklight.js:5134 before: initOptions.onSuccess
    worklight.js:5134 after: initOptions.onSuccess
    worklight.js:5134 wlclient init success
    worklight.js:5134 Request [/MyProject/apps/services/loguploader]
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134
    worklight.js:5134 Request [/MyProject/apps/services/loguploader]
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134
    worklight.js:5134 response [/MyProject/apps/services/loguploader] success: 
    worklight.js:5701 Client logs successfully sent to the server
    worklight.js:5134 response [/MyProject/apps/services/loguploader] success: 
    worklight.js:5701 Client logs successfully sent to the server
    worklight.js:5134 Piggybacking event transmission
    worklight.js:5134 Flush called
    worklight.js:5134 Request [/MyProject/apps/services/api/MyApp/iphone/heartbeat]
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134
    worklight.js:5134 response [/MyProject/apps/services/api/MyApp/iphone/heartbeat] success: 
    worklight.js:5134 Heartbeat sent successfully
    worklight.js:5134 Piggybacking event transmission
    worklight.js:5134 Flush called
    worklight.js:5134 Request [/MyProject/apps/services/api/MyApp/iphone/heartbeat]
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134
    worklight.js:5134 response [/MyProject/apps/services/api/MyApp/iphone/heartbeat] success: 
    worklight.js:5134 Heartbeat sent successfully
    worklight.js:5134 Piggybacking event transmission
    worklight.js:5134 Flush called
    worklight.js:5134 Request [/MyProject/apps/services/api/MyApp/iphone/heartbeat]
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134
    worklight.js:5134 response [/MyProject/apps/services/api/MyApp/iphone/heartbeat] success: 
    worklight.js:5134 Heartbeat sent successfully
    worklight.js:5134 Piggybacking event transmission
    worklight.js:5134 Flush called
    worklight.js:5134 Request [/MyProject/apps/services/api/MyApp/iphone/heartbeat]
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134
    worklight.js:5134 response [/MyProject/apps/services/api/MyApp/iphone/heartbeat] success: 
    worklight.js:5134 Heartbeat sent successfully
    worklight.js:5134 Piggybacking event transmission
    worklight.js:5134 Flush called
    worklight.js:5134 Request [/MyProject/apps/services/api/MyApp/iphone/heartbeat]
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134
    worklight.js:5134 response [/MyProject/apps/services/api/MyApp/iphone/heartbeat] success: 
    worklight.js:5134 Heartbeat sent successfully
    worklight.js:5134 Piggybacking event transmission
    worklight.js:5134 Flush called
    worklight.js:5134 Request [/MyProject/apps/services/api/MyApp/iphone/heartbeat]
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134
    worklight.js:5134 response [/MyProject/apps/services/api/MyApp/iphone/heartbeat] success: 
    worklight.js:5134 Heartbeat sent successfully
    worklight.js:5134 Piggybacking event transmission
    worklight.js:5134 Flush called
    worklight.js:5134 Request [/MyProject/apps/services/api/MyApp/iphone/heartbeat]
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134
    worklight.js:5134 response [/MyProject/apps/services/api/MyApp/iphone/heartbeat] success: 
    worklight.js:5134 Heartbeat sent successfully
    worklight.js:5134 Piggybacking event transmission
    worklight.js:5134 Flush called
    worklight.js:5134 Request [/MyProject/apps/services/api/MyApp/iphone/heartbeat]
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134
    worklight.js:5134 response [/MyProject/apps/services/api/MyApp/iphone/heartbeat] success: 
    worklight.js:5134 Heartbeat sent successfully
    worklight.js:5134 Piggybacking event transmission
    worklight.js:5134 Flush called
    worklight.js:5134 Request [/MyProject/apps/services/api/MyApp/iphone/heartbeat]
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134PUBLIC_API.(anonymous function) @ worklight.js:5520window.WLJSX.Ajax.WLRequest.WLJSX.Class.create.createRequestHeaders @ worklight.js:3337window.WLJSX.Ajax.WLRequest.WLJSX.Class.create.sendRequest @ worklight.js:3395window.WLJSX.Ajax.WLRequest.WLJSX.Class.create.initialize @ worklight.js:3309klass @ worklight.js:527sendHeartBeat @ worklight.js:7276onTimerEvent @ worklight.js:896(anonymous function) @ worklight.js:959
    worklight.js:5134 response [/MyProject/apps/services/api/MyApp/iphone/heartbeat] success: 
    worklight.js:5134 Heartbeat sent successfully
    worklight.js:5134 Piggybacking event transmission
    worklight.js:5134 Flush called

我注意到当我使用 Eclipse 构建项目和从 cli 构建项目时写入的文件之间存在日期编号差异......是否有一种简单的方法来检查和获取 CLI 的更新?

(为了清楚起见,我们在 Eclipse 中使用 Studio 时看不到这个问题。)

4

2 回答 2

1

这是完全可以预料的。

从预览 URL 看来,您正在查看实际上只加载 Web 资源的“简单预览”——在这种情况下,Cordova 确实不可用,因为 Cordova 仅在预览移动浏览器模拟器中的实际应用程序或在特定环境的 IDE(Xcode、Android Emulator 等)中。

如果您将在移动浏览器模拟器中启动您的应用程序 - 此工具通过模仿它来提供一些 Cordova 功能。

如果您将采用 MBS 预览 URL,例如以下 - 您将不会看到任何错误: http: //10.0.0.3 :10080/_MobileBrowserSimulator/index.html?webpage=/test/apps/services/preview/test /iphone/1.0/&platform=ios.iphone

但是,如果您随后“剥离” MBS 并预览以下内容 - 您将看到相同的错误:http: //10.0.0.3 :10080/test/apps/services/preview/test/iphone/1.0/default/索引.html

http://10.0.0.3:10080/test/apps/services/preview/test/iphone/1.0/default/worklight/cordova.js 加载资源失败:服务器响应状态为404(未找到)_mbs_cordova_sim_load_js @科尔多瓦.js:19

2015-06-25 20:01:08.608 cordova.js:24 Uncaught ReferenceError:cordova 未定义

于 2015-06-25T17:05:38.737 回答
0

正如 Idan 解释的那样,这是意料之中的。

我是用 开始预览的mfp preview --noshell。如果我 drop --noshell,它使用 MobileBrowserSimulator 链接,我不会收到这些错误。

于 2015-06-25T17:43:08.463 回答