Frage

I am using greenDao to access database in my Android phone. Everything seems fine, and complied. But when I run the program, it crashed at DaoMaster.java -> OpenHelper class, onCreate method at createAllTables(db, false);

Below are the Exception message:

>05-03 15:40:34.109: E/AndroidRuntime(28587): FATAL EXCEPTION: main
05-03 15:40:34.109: E/AndroidRuntime(28587): java.lang.NoClassDefFoundError: com.hook38.sporttimer.model.sql.DaoMaster
05-03 15:40:34.109: E/AndroidRuntime(28587):    at com.hook38.sporttimer.model.sql.DaoMaster$OpenHelper.onCreate(DaoMaster.java:42)
05-03 15:40:34.109: E/AndroidRuntime(28587):    at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:165)
05-03 15:40:34.109: E/AndroidRuntime(28587):    at com.hook38.sporttimer.controller.CountdownTimerStoreController.<init>(CountdownTimerStoreController.java:32)
05-03 15:40:34.109: E/AndroidRuntime(28587):    at com.hook38.sporttimer.controller.CountdownTimerController.<init>(CountdownTimerController.java:57)
05-03 15:40:34.109: E/AndroidRuntime(28587):    at com.hook38.sporttimer.CountDownTimerActivity.onCreate(CountDownTimerActivity.java:49)
05-03 15:40:34.109: E/AndroidRuntime(28587):    at android.app.Activity.performCreate(Activity.java:4465)
05-03 15:40:34.109: E/AndroidRuntime(28587):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
05-03 15:40:34.109: E/AndroidRuntime(28587):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
05-03 15:40:34.109: E/AndroidRuntime(28587):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-03 15:40:34.109: E/AndroidRuntime(28587):    at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-03 15:40:34.109: E/AndroidRuntime(28587):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-03 15:40:34.109: E/AndroidRuntime(28587):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-03 15:40:34.109: E/AndroidRuntime(28587):    at android.os.Looper.loop(Looper.java:137)
05-03 15:40:34.109: E/AndroidRuntime(28587):    at android.app.ActivityThread.main(ActivityThread.java:4424)
05-03 15:40:34.109: E/AndroidRuntime(28587):    at java.lang.reflect.Method.invokeNative(Native Method)
05-03 15:40:34.109: E/AndroidRuntime(28587):    at java.lang.reflect.Method.invoke(Method.java:511)
05-03 15:40:34.109: E/AndroidRuntime(28587):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-03 15:40:34.109: E/AndroidRuntime(28587):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-03 15:40:34.109: E/AndroidRuntime(28587):    at dalvik.system.NativeStart.main(Native Method)

I did some research on NoClassDefFoundError, and it means CLASSPATH was not set properly. but I checked the build path, greenDao.jar is in the library. Is there something I miss out??

War es hilfreich?

Lösung

I solved the problem. I was using the greenDao.jar file from the DaoExample project. The way to solve this is... remove the original greenDao.jar from my java build path. Make a folder call libs under my project. copy the geenDao.jar file from the libs folder in DaoExample project, and paste it into the libs file in my own project. Go to Java build path, libraries, import jar, and add the newly pasted jar file. wala~

Andere Tipps

The solution is ultra simple - Ensure Maven Dependencies are exported:

  1. Project Properties -> Java Build Path -> Order and Export -> Tick Maven Dependencies Project Properties
  2. Clean Project
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top