尝试安装ActiveAndroid但获取ClassNotFoundException

时间:2013-07-09 18:21:41

标签: activeandroid

我正在尝试从Pardom实现ActiveAndroid数据库包。我创建了一个简单的自定义类:

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();
    }

}

并将以下内容添加到Manifest:

 <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时,应用程序会加载。

1 个答案:

答案 0 :(得分:3)

好的我得到了答案。复制已下载的ActiveAndroid .jar ,并将其放入 libs / 文件夹。

然后,在Eclipse中,打开 libs 文件夹,右键单击 .jar ,然后将其添加到构建路径中。

Source