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)```
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With