'Execution failed for task ':app:compileDevDebugAndroidTestJavaWithJavac'

I am trying to run a command ./gradlew app:assembleAndroidTest inside android directory of my app in order to build an app-debug-androidTest.apk under androidTest directory.

But my build is failed with the following errors:

> Task :app:compileDevDebugAndroidTestJavaWithJavac
C:\Users\Noyruto\sources\repos\limitless-app\android\app\src\androidTest\java\ph\phoenixfuels\limitless\MainActivityTest.java:11: error: cannot find symbol
  public ActivityTestRule<MainActivity> rule = new ActivityTestRule<>(MainActivity.class, true, false);
                          ^
  symbol:   class MainActivity
  location: class MainActivityTest
C:\Users\Noyruto\sources\repos\limitless-app\android\app\src\androidTest\java\ph\phoenixfuels\limitless\MainActivityTest.java:11: error: cannot find symbol
  public ActivityTestRule<MainActivity> rule = new ActivityTestRule<>(MainActivity.class, true, false);
                                                                      ^
  symbol:   class MainActivity
  location: class MainActivityTest
2 errors

> Task :app:compileDevDebugAndroidTestJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDevDebugAndroidTestJavaWithJavac'.

I don't think there's a problem with my MainActivityTest.java because I tried this in other flutter app, and it build successfully. Is it because my project has a flavor?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source