Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
345 views
in Technique[技术] by (71.8m points)

android - Error initializing Cordova: Class not found

I followed the tutorial of Phonegap from the official Phonegap.com site (getting started with Android).

I have created project with following all the steps.

  1. created activity and extended from "DroidGap" and added loadURL method from onCreate().
  2. Added cordova-2.0.0.js and cordova-2.0.0.jar on the respective folder.
  3. Added the jar file to the build path
  4. Loaded the js file from the html tag
  5. Added permissions from AndroidMainfeast.xml
  6. copied the xml folder containing "configs.xml"

Now I don't understand where's the problem. It is showing the below error as shown in the screenshot enter image description here

Here is my HTML file

<!DOCTYPE html>
<html>
  <head>
    <title>Notification Example</title>

    <script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
    <script type="text/javascript" charset="utf-8">

    // Wait for Cordova to load
    //
    document.addEventListener("deviceready", onDeviceReady, false);

    // Cordova is ready
    //
    function onDeviceReady() {
        // Empty
    }

    // Show a custom alert
    //
    function showAlert() {
        navigator.notification.alert(
            'You are the winner!',  // message
            'Game Over',            // title
            'Done'                  // buttonName
        );
    }

    // Beep three times
    //
    function playBeep() {
        navigator.notification.beep(3);
    }

    // Vibrate for 2 seconds
    //
    function vibrate() {
        navigator.notification.vibrate(2000);
    }

    </script>
  </head>
  <body>
    <p><a href="#" onclick="showAlert()">Show Alert</a></p>
    <p><a href="#" onclick="playBeep()">Play Beep</a></p>
    <p><a href="#" onclick="vibrate()">Vibrate</a></p>
  </body>
</html>

Any advice? Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It is config.xml not configs.xml.

Based on the logs I'm seeing you are missing this file in your apps res/xml directory. It is included as part of the distribution at lib/android/res/xml/config.xml so copy that file into your res/xml directory and you should be all set.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...