So, I get NoSuchMethodErrorwhen I run my Activity / Instrument tests from Android Studio, on a code line that tries to call a method in the library module from unit test.
So this is my test:
public class MainActivityTest extends ActivityInstrumentationTestCase2 {
public void testMainActivity() {
final MainActivity target = (MainActivity) getActivity();
MyLibarary.someStaticMethod();
}
What is the deal here? I defined my library as a “compile” dependency in build.gradle and it compiles just fine. The library is also called from the main application classes without any problems. This is only when I call it from the tests, it fails. My application and my tests are in the same module.
I tried to perform the clean, assembleDebug and assembleDebugTest task manually. No.
Project Structure:
Root
|
| |
| |
|
Android Studio v1.0.2
Gradle v1.0.0
" Android" "MyApp" Run/Debug AS .