我正在学习phonegap,在更新ADT之前,应用程序运行良好,这里是index.html
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>Hello World</title>
<script type="text/javascript" src="cordova-2.7.0.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<link rel="stylesheet" href="jquery.mobile-1.3.1.min.css" />
<script src="jquery-1.8.3.min.js"></script>
<script src="jquery.mobile-1.3.1.min.js"></script>
<script type="text/javascript">
app.initialize();
</script>
</head>
<body>
<div data-role="page" id="page_dashboard">
<script type="text/javascript" charset="utf-8" src="scripts/dashboard.js"></script>
<div data-role="header">
<h1>Dashboard</h1>
</div><!-- /header -->
<div data-role="content">
<p><a href="#page_login" data-role="button" id="button_login">Login</a></p>
<p><a href="#" data-role="button" id="button_logout">Logout</a></p>
</div><!-- /content -->
</div>
</body>
</html>
这是.java
package com.hkinterview;
import android.os.Bundle;
import org.apache.cordova.*;
public class hkinterview extends DroidGap
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}
}
错误:
05-30 07:27:49.223: E/AndroidRuntime(934): FATAL EXCEPTION: main
05-30 07:27:49.223: E/AndroidRuntime(934): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.hkinterview/com.hkinterview.hkinterview}: java.lang.ClassNotFoundException: Didn't find class "com.hkinterview.hkinterview" on path: /data/app/com.hkinterview-2.apk
05-30 07:27:49.223: E/AndroidRuntime(934): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
05-30 07:27:49.223: E/AndroidRuntime(934): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
05-30 07:27:49.223: E/AndroidRuntime(934): at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-30 07:27:49.223: E/AndroidRuntime(934): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
05-30 07:27:49.223: E/AndroidRuntime(934): at android.os.Handler.dispatchMessage(Handler.java:99)
05-30 07:27:49.223: E/AndroidRuntime(934): at android.os.Looper.loop(Looper.java:137)
05-30 07:27:49.223: E/AndroidRuntime(934): at android.app.ActivityThread.main(ActivityThread.java:5041)
05-30 07:27:49.223: E/AndroidRuntime(934): at java.lang.reflect.Method.invokeNative(Native Method)
05-30 07:27:49.223: E/AndroidRuntime(934): at java.lang.reflect.Method.invoke(Method.java:511)
05-30 07:27:49.223: E/AndroidRuntime(934): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-30 07:27:49.223: E/AndroidRuntime(934): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-30 07:27:49.223: E/AndroidRuntime(934): at dalvik.system.NativeStart.main(Native Method)
05-30 07:27:49.223: E/AndroidRuntime(934): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.hkinterview.hkinterview" on path: /data/app/com.hkinterview-2.apk
05-30 07:27:49.223: E/AndroidRuntime(934): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
05-30 07:27:49.223: E/AndroidRuntime(934): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-30 07:27:49.223: E/AndroidRuntime(934): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-30 07:27:49.223: E/AndroidRuntime(934): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
05-30 07:27:49.223: E/AndroidRuntime(934): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
05-30 07:27:49.223: E/AndroidRuntime(934): ... 11 more
05-30 07:31:17.932: E/Trace(992): error opening trace file: No such file or directory (2)
05-30 07:31:18.074: W/dalvikvm(992): Unable to resolve superclass of Lcom/hkinterview/hkinterview; (15)
05-30 07:31:18.123: W/dalvikvm(992): Link of class 'Lcom/hkinterview/hkinterview;' failed
05-30 07:31:18.123: D/AndroidRuntime(992): Shutting down VM
05-30 07:31:18.132: W/dalvikvm(992): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
05-30 07:31:18.154: E/AndroidRuntime(992): FATAL EXCEPTION: main
05-30 07:31:18.154: E/AndroidRuntime(992): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.hkinterview/com.hkinterview.hkinterview}: java.lang.ClassNotFoundException: Didn't find class "com.hkinterview.hkinterview" on path: /data/app/com.hkinterview-1.apk
05-30 07:31:18.154: E/AndroidRuntime(992): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
05-30 07:31:18.154: E/AndroidRuntime(992): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
05-30 07:31:18.154: E/AndroidRuntime(992): at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-30 07:31:18.154: E/AndroidRuntime(992): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
05-30 07:31:18.154: E/AndroidRuntime(992): at android.os.Handler.dispatchMessage(Handler.java:99)
05-30 07:31:18.154: E/AndroidRuntime(992): at android.os.Looper.loop(Looper.java:137)
05-30 07:31:18.154: E/AndroidRuntime(992): at android.app.ActivityThread.main(ActivityThread.java:5041)
05-30 07:31:18.154: E/AndroidRuntime(992): at java.lang.reflect.Method.invokeNative(Native Method)
05-30 07:31:18.154: E/AndroidRuntime(992): at java.lang.reflect.Method.invoke(Method.java:511)
05-30 07:31:18.154: E/AndroidRuntime(992): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-30 07:31:18.154: E/AndroidRuntime(992): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-30 07:31:18.154: E/AndroidRuntime(992): at dalvik.system.NativeStart.main(Native Method)
05-30 07:31:18.154: E/AndroidRuntime(992): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.hkinterview.hkinterview" on path: /data/app/com.hkinterview-1.apk
05-30 07:31:18.154: E/AndroidRuntime(992): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
05-30 07:31:18.154: E/AndroidRuntime(992): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-30 07:31:18.154: E/AndroidRuntime(992): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-30 07:31:18.154: E/AndroidRuntime(992): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
05-30 07:31:18.154: E/AndroidRuntime(992): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
05-30 07:31:18.154: E/AndroidRuntime(992): ... 11 more
---------------------清单----------------------
<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" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET"/>
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:hardwareAccelerated="true"
android:debuggable="true">
<activity android:name="hkinterview" android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
答案 0 :(得分:5)
@hkinterview
我有类似的问题,我解决了用户1971705提到的问题。
答案 1 :(得分:0)
嗨,你是adt版本是22,打开java构建路径,选择Order and Export, 并检查Android私有库。如果不选择它,则Adt22无法将libs库添加到项目中