google-developer-training / basic-android-kotlin-compose-training-tip-calculator

Apache License 2.0
61 stars 100 forks source link

Write automated tests: Android Basics with Compose - NoClassDefFoundError #240

Open AlperenImam0glu opened 1 month ago

AlperenImam0glu commented 1 month ago

TipCalculatorTests, the unit test class we created by following the “Write automated tests” codelab, gives an error when run. The TipUITests class created for Ui testing runs smoothly. At first I thought there was a problem in my own steps, but there is the same error in the test_solution branch. I couldn't find a solution to this problem.

Error message:

java.lang.NoClassDefFoundError: com/example/tiptime/MainActivityKt

Repository https://github.com/google-developer-training/basic-android-kotlin-compose-training-tip-calculator/tree/test_solution

AJThePro99 commented 1 month ago

Yes! I've been getting this error as well. ( I actually created the test not under test/java at first ) I am on windows (Notorious for backslashes), and I went in to create directory test/java but the pre-determined option was not there (Spoiler: It was test\java) So, I went with the closest looking one: androidTest/java

And, I wrote the unit test as it is in the same, and it worked flawlessly. But, when I went to the next section of the codelab, turns out I messed up. So, I started from scratch and properly followed the codelab, only to run into NoClassDefFoundError