【发布时间】:2017-02-22 12:42:06
【问题描述】:
我有一个带有 gradle 的多项目构建设置,其中包含多个 android 应用程序和库。
项目结构示例:
root (Project Root)
| android
| module1 (Android Application)
| module2 (Android Library)
| ios (in the future)
我只想将某些 gradle 插件应用于某些子项目。 (如android gradle 插件只对android 子项目)
因此,我将:android -> build.gradle 中的类路径依赖项和插件声明添加到两个android 子项目中::android:module1 -> build.gradle -> apply plugin: 'com.android.application'
和:android:module2 -> build.gradle -> apply plugin: 'com.android.library'
问题是gradle找不到android gradle插件:
错误:(1, 1) 评估项目“:Shoppr:presentation”时出现问题。 未找到 ID 为“com.android.application”的插件。
这也不是其他一些问题(Gradle 版本 3.1;Android Gradle 插件版本:2.2.1)中的版本问题,因为在 :root -> build.gradle 或 :android:moduleX -> build.gradle 中定义类路径依赖项时,一切都按预期工作。
:root -> build.gradle
allprojects {
repositories {
mavenCentral()
jcenter()
}
}
:android -> build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1' <-- Should only be applied for android project
}
}
:android:module1 -> build.gradle
apply plugin: 'com.android.application' --> Plugin with id 'com.android.application' not found.
:android:module2 -> build.gradle
apply plugin: 'com.android.library'
【问题讨论】:
标签: android gradle android-gradle-plugin