1
我試圖從Pardom實現ActiveAndroid數據庫包。我創建了一個簡單的自定義類:試圖安裝ActiveAndroid,但得到ClassNotFoundException
package com.xxx.xxxx;
import com.activeandroid.ActiveAndroid;
public class CardiologyApplication extends com.activeandroid.app.Application {
@Override
public void onCreate() {
super.onCreate();
ActiveAndroid.initialize(this);
}
@Override
public void onTerminate() {
super.onTerminate();
ActiveAndroid.dispose();
}
}
,並添加以下的清單:
<application
android:name="com.xxx.xxxx.CardiologyApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.MyTheme" >
<meta-data
android:name="AA_DB_NAME"
android:value="Cardiology2.db" />
<meta-data
android:name="AA_DB_VERSION"
android:value="1" />
<activity
android:name="com.xxx.xxxx.HomeActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustResize" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
但隨着該堆棧跟蹤應用程序崩潰:
07-09 19:08:37.019: E/AndroidRuntime(11494): FATAL EXCEPTION: main
07-09 19:08:37.019: E/AndroidRuntime(11494): java.lang.RuntimeException: Unable to instantiate application com.xxx.xxx.CardiologyApplication: java.lang.ClassNotFoundException: Didn't find class "com.xxx.xxxx.CardiologyApplication" on path: DexPathList[[zip file "/data/app/com.xxx.xxxx-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.mycqs.cardiologymcqs-2, /vendor/lib, /system/lib]]
07-09 19:08:37.019: E/AndroidRuntime(11494): at android.app.LoadedApk.makeApplication(LoadedApk.java:509)
07-09 19:08:37.019: E/AndroidRuntime(11494): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4605)
07-09 19:08:37.019: E/AndroidRuntime(11494): at android.app.ActivityThread.access$1400(ActivityThread.java:154)
07-09 19:08:37.019: E/AndroidRuntime(11494): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1366)
07-09 19:08:37.019: E/AndroidRuntime(11494): at android.os.Handler.dispatchMessage(Handler.java:99)
07-09 19:08:37.019: E/AndroidRuntime(11494): at android.os.Looper.loop(Looper.java:137)
07-09 19:08:37.019: E/AndroidRuntime(11494): at android.app.ActivityThread.main(ActivityThread.java:5368)
07-09 19:08:37.019: E/AndroidRuntime(11494): at java.lang.reflect.Method.invokeNative(Native Method)
07-09 19:08:37.019: E/AndroidRuntime(11494): at java.lang.reflect.Method.invoke(Method.java:525)
07-09 19:08:37.019: E/AndroidRuntime(11494): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
07-09 19:08:37.019: E/AndroidRuntime(11494): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
07-09 19:08:37.019: E/AndroidRuntime(11494): at dalvik.system.NativeStart.main(Native Method)
07-09 19:08:37.019: E/AndroidRuntime(11494): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.xxx.xxxx.CardiologyApplication" on path: DexPathList[[zip file "/data/app/com.xxx.xxxx-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.xxx.xxxx-2, /vendor/lib, /system/lib]]
07-09 19:08:37.019: E/AndroidRuntime(11494): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
07-09 19:08:37.019: E/AndroidRuntime(11494): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
07-09 19:08:37.019: E/AndroidRuntime(11494): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
07-09 19:08:37.019: E/AndroidRuntime(11494): at android.app.Instrumentation.newApplication(Instrumentation.java:992)
07-09 19:08:37.019: E/AndroidRuntime(11494): at android.app.LoadedApk.makeApplication(LoadedApk.java:504)
07-09 19:08:37.019: E/AndroidRuntime(11494): ... 11 more
我不知道這裏有什麼問題。我已經在java構建路徑中添加了.jar文件。然而我得到這個classnotfound異常。當我導入android.app.Application時,該應用程序會加載。
我得到了同樣的錯誤。添加ActiveAndroid.jar到構建路徑,但我仍然得到「無法實例化應用程序com.activeandroid.app.Application:java.lang.ClassNotFoundException」。 – Fuhrmann