Reputation: 938
EDIT
After more investigation, it discovered that this has ant test command also doesn't work, so it's not a IntelliJ issue.
There is some warnings at app launch which suggest that the problem comes from a wrong link with ormlite framework :
WARN/dalvikvm(22209): Class resolved by unexpected DEX: Lcom/example/android/app/noclassdef/module/dao/BaseBrowserDAO;(0x4051f5e8):0x98558 ref [Lcom/j256/ormlite/dao/Dao;] Lcom/j256/ormlite/dao/Dao;(0x4051f5e8):0x97ec0 WARN/dalvikvm(22209): (Lcom/example/android/app/noclassdef/module/dao/BaseBrowserDAO; had used a different Lcom/j256/ormlite/dao/Dao; during pre-verification) WARN/dalvikvm(22209): Link of class 'Lcom/example/android/app/noclassdef/module/dao/BaseBrowserDAO;' failed
But this only happen in the test project, the main project has no issues.
I found that since R17 the jar 'really' needs to be in libs directory, so ithought maybe i should copy the jars in the test project libs directory, but it didn't change anything.
Original
My Android test project doesn't run on Android, i get the following error :
java.lang.NoClassDefFoundError: com.mycompany.android.module.shop.database.MyDBHelper at com.mycompany.android.module.shop.dao.DAOFactory.(DAOFactory.java:51) at com.mycompany.android.module.shop.dao.DAOFactory.initSingleton(DAOFactory.java:58) at com.mycompany.android.app.shop.test.EShopBaseTestCase.setUp(EShopBaseTestCase.java:41) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154) at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448) Caused by: java.lang.ClassNotFoundException: com.mycompany.android.module.shop.database.MyDBHelper in loader dalvik.system.PathClassLoader[/system/framework/android.test.runner.jar:/data/app/com.mycompany.android.app.shop.test-1.apk:/mnt/asec/com.mycompany.android.app.shop-1/pkg.apk] at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240) at java.lang.ClassLoader.loadClass(ClassLoader.java:551) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) ... 12 more
The test run without any problem on Eclipse so i guess it's a configuration issue.
The 'missing' class is a source class of the App, it's not in a jar nor in any external framework.
What puzzle me more is, looking at the stacktrace com.mycompany.android.module.shop.dao.DAOFactory is present but not com.mycompany.android.module.shop.database.MyDBHelper (which are in the same project...)
Anyone with an idea ? I've been stuck on it for some time now. It's not the first time I'm using test project with IntelliJ so I compared my configuration with working project but i found no differences at all...
Upvotes: 1
Views: 1568
Reputation: 938
Ok, actually the important message was
[...] had used a different Lcom/j256/ormlite/dao/Dao; during pre-verification
Which means that my ormlite jars where copied in each project instead of being exported properly in the main project.
Just checking the "export" checkbox on the jar solve the situation.
I was greatly help by FragmentActivity can not be tested via ActivityInstrumentationTestCase2
Upvotes: 2