我刚开始使用 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>