Build error when I use patrol cli command to test native screen

333 Views Asked by At

Getting below build errors when i use below patrol cli command to run test

patrol test --target integration_test/example_test.dart

**Build error 1 - Execution failed for task ':video_player_android:compileDebugJavaWithJavac'. > Compilation failed; see the compiler error output for details.

Build error 2 - * What went wrong: java.lang.StackOverflowError (no error message)**

Below is the code

void main() {
  patrolTest('demo', nativeAutomation: true, (PatrolTester $) async {
    await $.pumpWidgetAndSettle(AwesomeApp());
    // prepare network conditions
    await $.native.enableCellular();
    await $.native.disableWifi();

    // toggle system theme
    await $.native.enableDarkMode();

    // handle native location permission request dialog
    await $.native.selectFineLocation();
    await $.native.grantPermissionWhenInUse();

    // tap on the first notification
    await $.native.openNotifications();
    await $.native.tapOnNotificationByIndex(0);
  });
}

Build should be successful and should be able to run the test successfully.

1

There are 1 best solutions below

0
On

This is happening for incompatible gradle and java versions.

To check the versions try cd android && ./gradlew -v

------------------------------------------------------------
Gradle 7.5.1 # This version has to be supported by the JVM version below
------------------------------------------------------------

Build time:   2022-08-05 21:17:56 UTC
Revision:     d1daa0cbf1a0103000b71484e1dbfe096e095918

Kotlin:       1.6.21
Groovy:       3.0.10
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          17.x.x # or 11.x.x or 8.x.x
OS:           Mac OS X 13.4 aarch64

Now, install the correct jvm and set it up in .zshrc or .bashrc file

  1. Find out the correct jdk for your gradle version; say it is openjdk@17
  2. Install JVM (openjdk@17)
    brew install openjdk@17
    # follow instructions for symbolic linking in the terminal 
    
  3. Setup environment variables
    export JAVA_HOME="/opt/homebrew/opt/openjdk@17"
    export PATH="$JAVA_HOME/bin:$PATH"
    
  4. Source your .rc file
    source ~/.zshrc # or ~/.bashrc
    
  5. Reopen vscode or android studio or vim for the updated config to take effect