Android gradle模块循环依赖

标签 android gradle android-module

连接模块应用程序并出现以下错误:

Circular dependency between the following tasks:
:app:processDebugResources
\--- :app:processDebugResources (*)

模块结构

/app
|--base
|--authfire

将这一行添加到 authfire gradle 后出现错误 api项目(路径:':app')

我真正需要的是简单地使用authfire内根app中的MainActivity类来启动MainActivity。如果您有任何帮助,我们将不胜感激。

: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

    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

}

谢谢!

最佳答案

将两个模块使用的公共(public)/共享代码移动到另一个模块,例如common: 我们有,

公共(public)模块

模块 1 依赖于common

模块 2 依赖于common

等等.. 这样你就不会遇到循环依赖问题

关于Android gradle模块循环依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64971442/

相关文章:

java - 如何使用fft检测环境

android - 检查 TextView 是否完全被文本填充

android - Gradle error debugCompileClasspath' to contain exactly one file, however, it contains no files, 添加新的动态功能模块时

android - 从大型 Android 项目中提取和翻译多个 strings.xml 文件的最佳方法

android如何访问功能模块xml文件中的基本模块可绘制对象

android - 如何检查当前图像资源附加到android xml中的ImageView?

android - 与observeOn组合时RxJava的startsWith操作符被忽略

android - 库依赖资源覆盖 Android 中的主要源集

java - 在 Gradle 中使用 DBDeploy 并使用 hibernate 作为 ORM

android - 在 Gradle 中通过 Build Flavors 使用替代资源