1

当我运行我的应用程序时,我使用 php 文件从 phonegap 制作了简单的登录页面,那会出现错误。如何解决错误,这样的错误

  1. 找不到从方法 org.apache.cordova.CordovaWebViewClient.generateWebResourceResponse 引用的类 'android.webkit.WebResourceResponse'
  2. TypeError:表达式“l.attr”[未定义]的结果不是函数。在文件:///android_asset/www/jquery.mobile-1.0a3.min.js:49

我的日志猫

08-22 12:25:59.439: I/dalvikvm(302): Could not find method android.webkit.WebView.<init>, referenced from method org.apache.cordova.CordovaWebView.<init>
    08-22 12:25:59.439: W/dalvikvm(302): VFY: unable to resolve direct method 3117: Landroid/webkit/WebView;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;IZ)V
    08-22 12:25:59.439: D/dalvikvm(302): VFY: replacing opcode 0x70 at 0x0001
    08-22 12:25:59.439: D/dalvikvm(302): VFY: dead code 0x0004-0059 in Lorg/apache/cordova/CordovaWebView;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;IZ)V
    08-22 12:25:59.730: I/CordovaLog(302): config.xml missing, reverting to cordova.xml
    08-22 12:25:59.739: I/CordovaLog(302): Changing log level to DEBUG(3)
    08-22 12:25:59.739: I/CordovaLog(302): Found preference for useBrowserHistory=false
    08-22 12:25:59.739: D/CordovaLog(302): Found preference for useBrowserHistory=false
    08-22 12:25:59.790: E/dalvikvm(302): Could not find class 'android.webkit.WebResourceResponse', referenced from method org.apache.cordova.CordovaWebViewClient.generateWebResourceResponse
    08-22 12:25:59.790: W/dalvikvm(302): VFY: unable to resolve new-instance 452 (Landroid/webkit/WebResourceResponse;) in Lorg/apache/cordova/CordovaWebViewClient;
    08-22 12:25:59.790: D/dalvikvm(302): VFY: replacing opcode 0x22 at 0x0046
    08-22 12:25:59.790: W/dalvikvm(302): VFY: unable to find class referenced in signature (Landroid/webkit/WebResourceResponse;)
    08-22 12:25:59.790: D/dalvikvm(302): VFY: dead code 0x0048-004c in Lorg/apache/cordova/CordovaWebViewClient;.generateWebResourceResponse (Ljava/lang/String;)Landroid/webkit/WebResourceResponse;
    08-22 12:26:00.059: W/dalvikvm(302): VFY: unable to find class referenced in signature (Landroid/webkit/WebResourceResponse;)
    08-22 12:26:00.069: W/dalvikvm(302): VFY: unable to find class referenced in signature (Landroid/webkit/WebResourceResponse;)
    08-22 12:26:00.069: I/dalvikvm(302): Could not find method android.webkit.WebViewClient.shouldInterceptRequest, referenced from method org.apache.cordova.CordovaWebViewClient.shouldInterceptRequest
    08-22 12:26:00.080: W/dalvikvm(302): VFY: unable to resolve virtual method 3129: Landroid/webkit/WebViewClient;.shouldInterceptRequest (Landroid/webkit/WebView;Ljava/lang/String;)Landroid/webkit/WebResourceResponse;
    08-22 12:26:00.080: D/dalvikvm(302): VFY: replacing opcode 0x6f at 0x0015
    08-22 12:26:00.080: D/dalvikvm(302): VFY: dead code 0x0018-0019 in Lorg/apache/cordova/CordovaWebViewClient;.shouldInterceptRequest (Landroid/webkit/WebView;Ljava/lang/String;)Landroid/webkit/WebResourceResponse;
    08-22 12:26:00.080: D/DroidGap(302): DroidGap.init()
    08-22 12:26:00.140: D/CordovaWebView(302): >>> loadUrl(file:///android_asset/www/index.html)
    08-22 12:26:00.140: D/PluginManager(302): init()
    08-22 12:26:00.149: I/PluginManager(302): Using plugins.xml instead of config.xml.  plugins.xml will eventually be deprecated
    08-22 12:26:00.341: D/CordovaWebView(302): >>> loadUrlNow()
    08-22 12:26:00.529: D/SoftKeyboardDetect(302): Ignore this event
    08-22 12:26:00.779: D/SoftKeyboardDetect(302): Ignore this event
    08-22 12:26:01.130: D/DroidGap(302): onMessage(onPageStarted,file:///android_asset/www/index.html)
    08-22 12:26:01.889: D/dalvikvm(302): GC_FOR_MALLOC freed 1963 objects / 156568 bytes in 412ms
    08-22 12:26:07.049: D/Cordova(302): onPageFinished(file:///android_asset/www/index.html)
    08-22 12:26:07.049: D/CordovaWebView(302): >>> loadUrlNow()
    08-22 12:26:07.049: D/DroidGap(302): onMessage(onNativeReady,null)
    08-22 12:26:07.049: D/DroidGap(302): onMessage(onPageFinished,file:///android_asset/www/index.html)
    08-22 12:26:07.330: I/Database(302): sqlite returned: error code = 14, msg = cannot open file at source line 25467
    08-22 12:26:07.719: D/DroidGap(302): onMessage(networkconnection,3g)
    08-22 12:26:07.799: D/DroidGap(302): onMessage(spinner,stop)
    08-22 12:26:09.129: D/DroidGap(302): onMessage(spinner,stop)
    08-22 12:26:14.079: D/dalvikvm(302): GC_FOR_MALLOC freed 2869 objects / 442888 bytes in 53ms
    08-22 12:26:25.599: D/CordovaLog(302): TypeError: Result of expression 'l.attr' [undefined] is not a function.
    08-22 12:26:25.599: D/CordovaLog(302): file:///android_asset/www/jquery.mobile-1.0a3.min.js: Line 49 : TypeError: Result of expression 'l.attr' [undefined] is not a function.
    08-22 12:26:25.599: E/Web Console(302): TypeError: Result of expression 'l.attr' [undefined] is not a function. at file:///android_asset/www/jquery.mobile-1.0a3.min.js:49
    08-22 12:26:25.620: D/DroidGap(302): onMessage(onPageStarted,file:///android_asset/www/index.html)
    08-22 12:26:30.729: D/Cordova(302): onPageFinished(file:///android_asset/www/index.html)
    08-22 12:26:30.729: D/CordovaWebView(302): >>> loadUrlNow()
    08-22 12:26:30.740: D/DroidGap(302): onMessage(onNativeReady,null)
    08-22 12:26:30.740: D/DroidGap(302): onMessage(onPageFinished,file:///android_asset/www/index.html)
    08-22 12:26:31.000: I/Database(302): sqlite returned: error code = 14, msg = cannot open file at source line 25467
    08-22 12:26:31.320: D/DroidGap(302): onMessage(spinner,stop)

我的 html 文件是

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login</title>
 <link rel="stylesheet" href="jquery.mobile-1.0a3.min.css" />
 <script type="text/javascript" src="jquery-1.5.min.js"></script>
 <script type="text/javascript" src="jquery.mobile-1.0a3.min.js"></script>
 <script type="text/javascript" src="cordova-2.0.0.js"></script>
 <script type="text/javascript" src="jquery-latest.js"></script>
 <script type="text/javascript">

    $(document).bind( "mobileinit",function() {

        $.support.cors = true;
        $.mobile.allowCrossDomainPages = true;

        $('#loginForm').submit(function() {
            $('#output').html('Connecting....');
            var postTo = 'http://xemesolutions.com/kirit/login.php';

            $.post(postTo,
            {
                username: $('[name=username]').val() , 
                password: $('[name=password]').val()
            },

            function(data) {
                if(data.message) {
                    $('#output').html(data.message);
                } else {
                    $('#output').html('Could not connect');
                }
            }
            ,'json');

        return false;
    });
 });

</script>

</head>
<body>

<div data-role="page" id="foo">

 <div data-role="header">
     <h1>Login</h1>
 </div>

 <div data-role="content">

 <p id="output"></p>
 <p>
 <form method="post" id="loginForm">
 name: <input type="text" name="username"><br />
 Password: <input type="password" name="password"><br />
 <input type="submit" value="Login">
 <a href="http://api.jquery.com/load/" >Page</a>
 </form>
 </p>
 </div>

 <div data-role="footer">
 <h4>Footer</h4>
 </div>
</div>

</body>
</html>

我的 php 文件是

<?php

if(isset($_POST['username']) && isset($_POST['password'])){

 // do logic for logining in (usually query your db)
 if ($_POST['username'] == 'test' && $_POST['password'] == 'test') {
 $data['success'] = true;
 $data['message'] = 'Login succesful';
 } else {
 $data['success'] = false;
 $data['message'] = 'Login failed';
 }
 // return json
 echo json_encode($data);
}
?>

和我的cordova.xml

<access origin="http://xemesolutions.com/kirit/*"/>

如何解决我想尝试很多次但我没有解决。请帮我。我该怎么办?

4

0 回答 0