Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to refer app module classes in dynamic feature module when running unit test cases

Our project has dynamic feature module with a dependency on the app module. The classes in the dynamic feature module have a dependency on app module.

We also have unit test cases in the dynamic module testing individual classes of the dynamic module. The unit tests run fine when run through android studio. Got an error running unit tests using gradlew.

Below is the error:

./gradlew :dynamic_feature1:testDebugUnitTest Getting the following error:

15:40:13.225 [DEBUG] [TestEventLogger]
15:40:13.225 [DEBUG] [TestEventLogger] com.example.dynamic_feature1.DynamicPresenterTest > testXyz FAILED
15:40:13.225 [DEBUG] [TestEventLogger]     java.lang.NoClassDefFoundError: com/example/dynamicfeature/AppBase
15:40:13.225 [DEBUG] [TestEventLogger]         at java.lang.ClassLoader.defineClass1(Native Method)
15:40:13.225 [DEBUG] [TestEventLogger]         at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
15:40:13.225 [DEBUG] [TestEventLogger]         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)```
like image 979
chaitanya prasad movva Avatar asked May 07 '19 16:05

chaitanya prasad movva


1 Answers

To fix the java.lang.NoClassDefFoundError: com/example/dynamicfeature/AppBase issue, try this command:

./gradlew test

see Android jUnit Test java.lang.NoClassDefFoundError: android/database/sqlite/SQLiteOpenHelper

like image 193
edwardandroid7995 Avatar answered Oct 28 '22 16:10

edwardandroid7995