flutter 使用patrol cli命令测试本机屏幕时发生构建错误

e5nqia27  于 2023-06-24  发布在  Flutter
关注(0)|答案(1)|浏览(130)

当我使用下面的巡逻cli命令运行测试时,得到下面的构建错误
巡视测试--target integration_test/example_test.dart

**生成错误1 -执行任务“:video_player_android:compileDebugJavaWithJavac”失败。>编译失败;请参阅编译器错误输出的详细信息。

Build error 2 - * What went wrong:java.lang.StackOverflowError(无错误消息)**
下面是代码

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);
  });
}

生成应该成功,并且应该能够成功运行测试。

bxgwgixi

bxgwgixi1#

不兼容的gradlejava版本会发生这种情况。
要检查版本,请尝试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

现在,安装正确的jvm并在.zshrc.bashrc文件中进行设置
1.找出适合您的gradle版本的正确jdk;假设是openjdk@17
1.安装JVM(openjdk@17

brew install openjdk@17
# follow instructions for symbolic linking in the terminal

1.设置环境变量

export JAVA_HOME="/opt/homebrew/opt/openjdk@17"
export PATH="$JAVA_HOME/bin:$PATH"

1.源.rc文件

source ~/.zshrc # or ~/.bashrc

1.重新打开vscodeandroid studiovim,使更新的配置生效

相关问题