2

我刚开始使用 phonegap,所以我完成了本教程 [http://docs.phonegap.com/en/2.0.0/guide_getting-started_android_index.md.html][1] [1]: http://docs. phonegap.com/en/2.0.0/guide_getting-started_android_index.md.html

目录:

   08-09 14:36:21.752: E/AndroidRuntime(543): FATAL EXCEPTION: main
08-09 14:36:21.752: E/AndroidRuntime(543): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.apache.cordova.example/org.apache.cordova.example.cordovaExample}: java.lang.ClassNotFoundException: org.apache.cordova.example.cordovaExample in loader dalvik.system.PathClassLoader[/data/app/org.apache.cordova.example-1.apk]
08-09 14:36:21.752: E/AndroidRuntime(543):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
08-09 14:36:21.752: E/AndroidRuntime(543):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
08-09 14:36:21.752: E/AndroidRuntime(543):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
08-09 14:36:21.752: E/AndroidRuntime(543):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
08-09 14:36:21.752: E/AndroidRuntime(543):  at android.os.Handler.dispatchMessage(Handler.java:99)
08-09 14:36:21.752: E/AndroidRuntime(543):  at android.os.Looper.loop(Looper.java:123)
08-09 14:36:21.752: E/AndroidRuntime(543):  at android.app.ActivityThread.main(ActivityThread.java:4627)
08-09 14:36:21.752: E/AndroidRuntime(543):  at java.lang.reflect.Method.invokeNative(Native Method)
08-09 14:36:21.752: E/AndroidRuntime(543):  at java.lang.reflect.Method.invoke(Method.java:521)
08-09 14:36:21.752: E/AndroidRuntime(543):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-09 14:36:21.752: E/AndroidRuntime(543):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-09 14:36:21.752: E/AndroidRuntime(543):  at dalvik.system.NativeStart.main(Native Method)
08-09 14:36:21.752: E/AndroidRuntime(543): Caused by: java.lang.ClassNotFoundException: org.apache.cordova.example.cordovaExample in loader dalvik.system.PathClassLoader[/data/app/org.apache.cordova.example-1.apk]
08-09 14:36:21.752: E/AndroidRuntime(543):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
08-09 14:36:21.752: E/AndroidRuntime(543):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
08-09 14:36:21.752: E/AndroidRuntime(543):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
08-09 14:36:21.752: E/AndroidRuntime(543):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
08-09 14:36:21.752: E/AndroidRuntime(543):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
08-09 14:36:21.752: E/AndroidRuntime(543):  ... 11 more

更新的 MainActivity:

package org.apache.cordova.example;

import org.apache.cordova.DroidGap;

import android.os.Bundle;

public class MainActivity extends DroidGap
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        super.loadUrl("file:///android_asset/www/index.html");
    }
}

笔记:

我的 .jar 文件夹称为“libs”。

我添加了 cordova2.0.0.jar 作为构建路径。

我尝试添加 plugins.xml:

<?xml version="1.0" encoding="utf-8"?>
<plugins>
    <plugin name="App" value="com.phonegap.App"/>
    <plugin name="Geolocation" value="com.phonegap.GeoBroker"/>
    <plugin name="Device" value="com.phonegap.Device"/>
    <plugin name="Accelerometer" value="com.phonegap.AccelListener"/>
    <plugin name="Compass" value="com.phonegap.CompassListener"/>
    <plugin name="Media" value="com.phonegap.AudioHandler"/>
    <plugin name="Camera" value="com.phonegap.CameraLauncher"/>
    <plugin name="Contacts" value="com.phonegap.ContactManager"/>
    <plugin name="Crypto" value="com.phonegap.CryptoHandler"/>
    <plugin name="File" value="com.phonegap.FileUtils"/>
    <plugin name="Network Status" value="com.phonegap.NetworkManager"/>
    <plugin name="Notification" value="com.phonegap.Notification"/>
    <plugin name="Storage" value="com.phonegap.Storage"/>
    <plugin name="Temperature" value="com.phonegap.TempListener"/>
    <plugin name="FileTransfer" value="com.phonegap.FileTransfer"/>
    <plugin name="Capture" value="com.phonegap.Capture"/>
</plugins>

清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:windowSoftInputMode="adjustPan"
      package="org.apache.cordova.example" android:versionName="1.1" android:versionCode="5">
    <supports-screens
        android:largeScreens="true"
        android:normalScreens="true"
        android:smallScreens="true"
        android:xlargeScreens="true"
        android:resizeable="true"
        android:anyDensity="true"
        />

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.RECEIVE_SMS" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.RECORD_VIDEO"/>
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />   
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />   
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.BROADCAST_STICKY" />


    <application android:icon="@drawable/icon" android:label="@string/app_name"
        android:debuggable="true">
        <activity android:name="cordovaExample" android:label="@string/app_name" 
                  android:configChanges="orientation|keyboardHidden">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

    <uses-sdk android:minSdkVersion="5" />
</manifest> 
4

3 回答 3

2

我猜您 manifest.xml 中提供的包/活动名称与您的 java 文件中的包/类名称不匹配。这就是它正在寻找的:

Caused by: java.lang.ClassNotFoundException:     org.apache.cordova.example.cordovaExample 

这就是它得到的:

package com.example.yourappname;
...
public class MainActivity extends DroidGap {
...
}

您的 manifest.xml 看起来如何?可能是复制粘贴错误;)

于 2012-08-10T11:22:54.010 回答
0

遇到了同样的问题,烦人……现在我得到了临时解决方案……从任何工作项目中复制以下文件并在当前项目中进行进度..

ant.properties
build.xml
proguard-project.txt
project.properties
.classpath
.project  

注意:一次替换所有文件..在更新工作空间时,我向我提出了这个问题..它对我有用..但没有得到确切的解决方案...
一次导入示例项目..Phonegap/lib/android/示例以便更好地理解。

于 2013-06-12T11:29:37.127 回答
0

我遇到了和你类似的问题。我跟着这个链接

我得到了同样的错误。我错误地复制了整个清单文件。但后来我恢复到 Eclipse 为我创建的清单,并且只更改了使用 phonegap 所需的部分。我按照上面链接中列出的步骤进行操作,它工作正常。(Ubuntu 10.04,Eclipse 开普勒)

于 2014-03-05T10:25:46.900 回答