【问题标题】:Async + ClickBusting + Cordova + Android Galaxy S4 = unexpected exit异步 + ClickBusting + Cordova + Android Galaxy S4 = 意外退出
【发布时间】:2013-10-18 21:09:20
【问题描述】:

This very small Cordova+AngularJS app 在运行 Android 4.2.2 的 Galaxy S4 上运行时退出(以“哦,嘿,我崩溃了,我要离开这里了!”之类的方式)。它在我测试过的所有其他设备上运行良好。例如,在运行 Android 4.1.2 的 Galaxy Note II 上没有问题。

www 目录的东西在浏览器中也可以正常工作,包括 S4/Android 4.2.2 设备上的浏览器。

所以这个错误似乎只发生在这段代码是:

  • 作为 Cordova 应用程序运行
  • 在运行 Android 4.2.2 的 Galaxy S4 上

复制行为的步骤

  1. 克隆the repo
  2. 使用 Cordova 创建 Android 可执行文件。安装了cordova 命令行工具和Android SDK:
    • cordova platform add android
    • cordova build
  3. 获取生成的 APK 并将其安装在运行 Android 4.2.2 的 Galaxy S4 上。如果您还没有,可以通过http://developer.samsung.com/remotetestlab免费测试。
  4. 启动应用程序。
  5. 触摸应用主屏幕上的文字。
  6. 等待几秒钟,应用程序将退出。

在我测试过的所有其他内容上,它都会加载颜色列表内容,这是预期的行为。

说了这么多,我的问题是:我该如何解决这个问题才不会崩溃?或者我该如何调试?

相关代码

这些文件都在 repo 中,但如果你不想点击,就到这里吧:

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Galaxy S4 + Android 4.2.2 + Cordova Crash</title>

    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1">
</head>
<body>
    <div id="ng-app" data-ng-app="main">

        <!-- Begin Templates -->
        <script type="text/ng-template" id="main">
            <a ng-click="showList()">On Galaxy S4, touch here, wait a few seconds, and the app will crash.</a>
        </script>

        <script type="text/ng-template" id="list">
        <progress data-ng-show="loading"></progress>
        <ol data-ng-hide="loading">
            <li data-ng-repeat="color in colors">
                {{color.name}}
            </li>
        </ol>
        </script>
        <!-- End Templates -->

        <div data-ng-view=""></div>
    </div>
    <script src="js/angular.js"></script>
    <script src="js/angular-mobile.js"></script>
    <script src="js/modules/main.js"></script>
    <script src="js/modules/list.js"></script>
</body>
</html>

main.js

(function () {
    'use strict';
    angular.module('main', ['ngMobile','list'])
    .config(['$routeProvider', function ($routeProvider) {
        $routeProvider
        .when('/', {templateUrl: 'main', controller: 'mainController'})
        .otherwise({redirectTo: '/'});
    }]).
    controller('mainController', ['$scope', '$location', function ($scope, $location) {
        $scope.showList = function () {
            $location.path('/list');
        };
    }]);
}());

list.js

(function () {
    'use strict';
    angular.module('list', [])
    .config(['$routeProvider', function ($routeProvider) {
        $routeProvider
        .when('/list', {templateUrl: 'list', controller: 'listController'});
    }])
    .controller(
        'listController',
        ['$scope', '$timeout', function ($scope, $timeout) {
            $scope.loading = true;

            var callback = function () {
                $scope.loading = false;
                $scope.colors = [
                    {name: 'Almost Blue'},
                    {name: 'Kind Of Blue'},
                    {name: 'Totally Not Blue'}
                ];
            };

            // Using $timeout to sort of fake an XHR just to rule out XHR as a cause
            $timeout(callback, 500);
        }]
    );
}());

日志

这会显示在 Android 日志中,至少在使用 http://developer.samsung.com/remotetestlab 时会显示:

ERROR|10-19 03:39:49.448|6938|6938||CallbackProxy|UPDATE_URL
ASSERT|10-19 03:39:49.493|6938|6953||libc|Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 6953 (WebViewCoreThre)

附加说明

我使用 Cordova 3.1.0 进行了尝试。我还在提交 28c41294bba746c75beae0ab26a42c8412cc665a (截至 2013 年 10 月 20 日,即今天,对 master 的最新提交)使用从 the cordova-android repo 编译的 cordova-3.2.0-dev.jar 进行了尝试。行为没有变化 - 应用仍然意外退出。

【问题讨论】:

  • 你可能不得不挖掘一个错误来获得任何帮助(谁知道呢)。您也许可以远程调试以获取更多信息 developers.google.com/chrome-developer-tools/docs/… 否则我可能会开始寻找日志文件。
  • 好点。我将出现在 Android 日志中的看似相关的内容添加到了问题的底部。至于调试,我试过调试,$timeout()调用中的回调永远不会执行。除此以外,一切都按预期运行。当然,它在其他设备上也能正常工作。 :-/
  • 根据你的日志,我发现了一些相关的东西,但不知道你还能做什么? comments.gmane.org/gmane.comp.handhelds.phonegap/44629 code.google.com/p/android/issues/detail?id=57518 stackoverflow.com/questions/14023291/… 你能把phonegap从等式中去掉吗?
  • 我删除了 PhoneGap 并使用 Cordova 编译,但应用程序仍然崩溃。所以我更新了github.com/Trott/s4-angular-phonegap-crash。我可以尝试删除 Cordova,但这非常令人生畏。尽管如此,我仍然可以向 Apache Cordova 项目提交一个错误,如果目前从事该项目的人没有任何想法或周期,那么我自己开始调试它。我预计会有一个学习曲线......
  • 认为你现在已经超过了我的薪酬等级......祝你好运,让全世界都知道它的进展。我以前没有听说过 Cordova,但它看起来非常棒,能够使用它会很高兴。

标签: javascript android asynchronous cordova samsung-mobile


【解决方案1】:

这是 S4 上三星的 Android 4.2.2 Webview 版本中的一个错误。当 S4 更新到 Android 4.3 时,问题就消失了。有可能的解决方法(想到 UA 嗅探,但这让我很难过——但你可以省略 S4/4.2.2 的点击破坏)。但解决方案确实掌握在三星手中。

详情请见the relevant issue in the Cordova Android JIRA

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-25
    相关资源
    最近更新 更多