【问题标题】:Could not find method bundle()找不到方法 bundle()
【发布时间】:2018-10-04 11:02:54
【问题描述】:

我正在尝试在我的项目中构建 appbundle。我按照官方指南中的步骤进行操作,但在 gradle 同步时出现以下错误。有什么问题?

   * What went wrong:
    A problem occurred evaluating project ':MyProject'.
    > Could not find method bundle() for arguments [build_4ng76ykxfhsfa1nuepa3fikmu$_run_closure5$_closure28@6448fs70] on object of type com.android.build.gradle.AppExtension.

我将android.enableAapt2=true 添加到 gradle.properties 文件并运行 ./gradlew --stop

【问题讨论】:

  • 请检查一下,gradle 插件版本。我认为插件相关的问题会存在。
  • @YogeshRathi 谢谢,完全忘记了 gradle 插件
  • 祝你好运,编码愉快:)

标签: android gradle android-app-bundle


【解决方案1】:

我错过了插件版本,如果有人面临相同的堆栈跟踪。 请检查插件版本。

将 Android gradle 插件版本更新为3.2.0 或更高版本

classpath "com.android.tools.build:gradle:3.2.0"

【讨论】:

    【解决方案2】:

    我相信您正在寻找的任务是bundleReleasebundleDebug

    【讨论】:

    • 我想我找到了问题所在。是 gradle 插件版本。
    【解决方案3】:
    signingConfigs {
        debug {
            keyAlias 'xxxxxx'
            keyPassword 'xxxxx'
            storeFile file('xxxxx')
            storePassword 'xxxxx'
        }
        releaseConfig {}
    }
    

    您可能丢失了花括号的signingConfigs {},我添加它然后一切都很好。

    你可以试试

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-06-18
      • 2019-12-09
      • 1970-01-01
      • 2016-05-19
      • 2015-07-20
      • 2013-01-08
      • 2020-03-17
      相关资源
      最近更新 更多