android - 插件指令在 gradle 文件中的什么位置?

标签 android android-studio gradle android-gradle-plugin gradle-plugin

我正在使用 Android Studio 和 gradle 开发一个 Android 项目。我从 Gradle 2.1+ 中看到,您可以使用新的插件指令包含插件,如下所示:

plugins {
  id "me.tatarka.retrolambda" version "3.2.5"
}

这条指令去哪里了?我必须将它放在哪个 gradle 文件中,嵌套在某个地方或只是附加在末尾?

最佳答案

这就是gradle documentation关于它:

The new plugins {} block does not support arbitrary Groovy code. It is constrained, in order to be idempotent (produce the same result every time) and side effect free (safe for Gradle to execute at any time).

The form is:

plugins { id «plugin id» version «plugin version» }

Where «plugin version» and «plugin id» must be constant, literal, strings. No other statements are allowed; their presence will cause a compilation error.

The plugins {} block must also be a top level statement in the buildscript. It cannot be nested inside another construct (e.g. an if-statement or for-loop).

The plugins {} block can currently only be used in a project's build script. It cannot be used in script plugins, the settings.gradle file or init scripts.

关于android - 插件指令在 gradle 文件中的什么位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36174957/

相关文章:

android - Admob Native 广告加载失败,错误代码为 0

java - 在 webView 中阻止键盘

android - com.diffplug.gradle.spotless && 任务清理(类型 : Delete){} Error:Cannot add task 'clean' as a task with that name already exists

android - android studio项目中没有dimens.xml

android - 使用 gradle 编译 Twitter4j

gradle - Jacoco Gradle 中的最小代码覆盖阈值

android - 一次使用半滑动viewpager android的两个 ListView

android - gradle-android中的apk范围有什么用?

android-studio - 尝试安装 Android Studio 时出错

java - 如何在Java代码中获取gradle jar list 属性(或通过Java变量进行设置)