[英]Android gradle modules circular dependency
Connecting module application and get following error:连接模块应用程序并出现以下错误:
Circular dependency between the following tasks:
:app:processDebugResources
\--- :app:processDebugResources (*)
Module structure模块结构
/app
|--base
|--authfire
Error appears after adding to authfire
gradle this line api project(path: ':app')
添加到
authfire
gradle 这条线api project(path: ':app')
后出现错误
What I actually need is simply use MainActivity
class from root app
inside authfire
for starting MainActivity
.我真正需要的只是使用
MainActivity
class 从authfire
中的根app
启动MainActivity
。 Woud be appreciate for any help.如有任何帮助,我们将不胜感激。
:app
gradle :app
gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-kapt'
apply from: '../dependencies.gradle'
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.alazar.tracker"
minSdkVersion 22
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
buildFeatures {
viewBinding = true
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation project(path: ':app:base')
implementation project(path: ':app:authfire')
implementation libs.kotlin
implementation libs.core
implementation libs.appcompat
implementation libs.lifecycle
implementation libs.constraint
implementation libs.material
testImplementation libs.testJunit
androidTestImplementation libs.androidTestJunit
androidTestImplementation libs.androidTestEspresso
// dagger
implementation libs.dagger
kapt libs.daggerKapt
}
:app:authfire
gradle :app:authfire
gradle
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'com.google.gms.google-services'
id 'kotlin-kapt'
}
apply from: '../../dependencies.gradle'
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
minSdkVersion 22
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding = true
}
}
dependencies {
//noinspection GradleDependency
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.72" // because of Firebase compatibility
}
dependencies {
api project(path: ':app')
api project(path: ':app:base')
implementation libs.core
implementation libs.appcompat
implementation libs.material
implementation libs.constraint
implementation libs.lifecycle
testImplementation libs.testJunit
androidTestImplementation libs.androidTestJunit
androidTestImplementation libs.androidTestEspresso
// Firebase
implementation platform('com.google.firebase:firebase-bom:26.0.0')
implementation 'com.google.firebase:firebase-auth-ktx:20.0.0'
implementation 'com.google.firebase:firebase-firestore-ktx:22.0.0'
// RX
implementation libs.rxKotlin
// dagger
implementation libs.dagger
kapt libs.daggerKapt
}
Thanks!谢谢!
Move the common/shared code used by the two modules to another module, say common
: we have,将两个模块使用的公共/共享代码移动到另一个模块,比如
common
:我们有,
common
module common
模块
module 1
depends on common
module 1
依赖于common
module 2
depends on common
module 2
依赖于common
and so on.. this way you won't have a circular dependency issue等等..这样你就不会有循环依赖问题
App is depending on authfire应用依赖于 authfire
authfire is depending on App authfire 取决于 App
That for sure make a loop.那肯定会形成一个循环。
it seems that in project: authfire you need to use some parameters from project: App.似乎在 project: authfire 中你需要使用 project: App 中的一些参数。 Solution whould be like this:
解决方案应该是这样的:
App is depending on authfire (that is ok)应用程序依赖于 authfire(没关系)
App is passing parameters to Project:authfire (that would be ok) (example of passing parameters is using broadcast)应用程序正在将参数传递给 Project:authfire(没问题)(传递参数的示例使用广播)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.