You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter项目集成webview_flutter_Android构建失败:Jar文件创建失败及未知属性‘android’报错求助

Flutter项目集成webview_flutter_Android构建失败:Jar文件创建失败及未知属性‘android’报错求助

大家好,我最近在尝试把Flutter项目运行到真实Android设备时卡壳了,折腾了好几个小时还是没解决,来这里求助各位大佬!

我的项目环境配置

  • Flutter版本:3.27.4
  • Android Gradle Plugin(AGP)版本:8.1.0(根目录build.gradle中classpath配置为 com.android.tools.build:gradle:8.1.0)
  • Gradle版本:8.2.1(distributionUrl为 https://services.gradle.org/distributions/gradle-8.2.1-all.zip)
  • JDK版本:先后尝试过18和17,当前使用JDK17,app级build.gradle配置如下:
compileOptions {
    sourceCompatibility JavaVersion.VERSION_17
    targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
    jvmTarget = '17'
}

完整报错日志

运行flutter run后,首先出现两个Gradle插件应用方式过时的警告(我知道后续需要迁移,但暂时应该不是构建失败的核心原因):

You are applying Flutter's app_plugin_loader Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block
You are applying Flutter's main Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block

紧接着是核心构建失败错误:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':webview_flutter_android'.
> java.util.concurrent.ExecutionException: org.gradle.api.GradleException: Failed to create Jar file /Users/davorstajcer/.gradle/caches/jars-9/18366b31678c0171857be093a3b8ec22/bcprov-jdk18on-1.79.jar.
> Failed to notify project evaluation listener.
> Could not get unknown property 'android' for project ':webview_flutter_android' of type org.gradle.api.Project.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 3m 13s
Error: Gradle task assembleDevDebug failed with exit code 1

我已尝试的排查步骤

  1. 切换JDK版本(17和18来回试),问题依旧;
  2. 执行./gradlew clean清理构建缓存,同时手动删除了本地.gradle/caches目录,重新构建还是报错;
  3. 检查webview_flutter插件版本,当前用的是最新稳定版,暂时没发现版本兼容性提示。

有没有朋友遇到过类似的问题?或者能给我一些新的排查方向?万分感谢!

内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.08 09:53:07