[英]Android Gradle build and circular dependency
I have an Android project in IntelliJ IDEA. 我在IntelliJ IDEA中有一个Android项目。 It consists of two modules: app and library.
它由两个模块组成:app和library。 App depends on library and library depends on app (Yes, it's not good, but I have what I have and can't change this).
应用程序依赖于库和库依赖于应用程序(是的,它不好,但我有我拥有的,不能改变这个)。 IDEA in project settings warn me about circular dependencies, but project builds correctly.
项目设置中的IDEA警告我循环依赖,但项目正确构建。 Project structure looks like this:
项目结构如下所示:
project
|__app
| |__src
| |__build.gradle
|__libarary
| |__src
| |__build.gradle
|__build.gradle
|__settings.gradle
Now I'm trying to migrate to new Android build system based on Gradle and have a trouble here. 现在我正在尝试迁移到基于Gradle的新Android构建系统,并在这里遇到麻烦。 In my
build.gradle
from app
module I add dependency on library
在
app
模块的build.gradle
,我添加了对library
依赖
compile project(":library")
Also I tryed to add dependency in library
on app
like 另外我试着在
app
上添加依赖library
compile project(":app")
But gets error from build system, when gradle trys to assemble library module: 但是当gradle试图组装库模块时,从构建系统中获取错误:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
> Module version project:app:unspecified depends on libraries but is not a library itself
What I can do with this without changing project structure 在不改变项目结构的情况下,我可以做些什么
This parameters have changed. 这些参数已经改变。
You should now refactor: 你现在应该重构:
In the library project use: 在图书馆项目中使用:
apply plugin: 'com.android.library' apply plugin:'com.android.library'
In the app project use: 在app项目中使用:
apply plugin: 'com.android.application' apply plugin:'com.android.application'
In the library project use: 在图书馆项目中使用:
apply plugin: 'android-library'
In the app project use: 在app项目中使用:
apply plugin: 'android'
Make sure you have the newest Android tools: 确保您拥有最新的Android工具:
classpath 'com.android.tools.build:gradle:0.5.+'
If you arrive here searching for the same error with Android 3.0 you should know the current workaround is: 如果您到达此处搜索与Android 3.0相同的错误,您应该知道当前的解决方法是:
downgrade to kotlinVersion = '1.1.2-2' 降级到kotlinVersion ='1.1.2-2'
and disable incremental build in gradle.properties kotlin.incremental=false 并在gradle.properties中禁用增量构建kotlin.incremental = false
The issue is planned for the next alpha https://issuetracker.google.com/issues/38447344 该问题计划用于下一个alpha https://issuetracker.google.com/issues/38447344
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.