【问题标题】:Android gradle modules circular dependencyAndroid gradle 模块循环依赖
【发布时间】:2020-11-23 15:35:00
【问题描述】:

连接模块应用程序并得到以下错误:

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

模块结构

/app
|--base
|--authfire

添加到authfire gradle这一行后出现错误 api project(path: ':app')

我真正需要的只是在authfire 中使用来自根appMainActivity 类来启动MainActivity。任何帮助都将不胜感激。

:appgradle

    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:authfiregradle

    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

}

谢谢!

【问题讨论】:

    标签: android gradle android-module


    【解决方案1】:

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

    common模块

    module 1 依赖于common

    module 2 依赖于common

    等等.. 这样你就不会有循环依赖问题了

    【讨论】:

    • 这个问题已经过时了
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-28
    • 2018-06-08
    • 2018-03-17
    • 2017-10-27
    • 2021-09-18
    • 2014-04-15
    相关资源
    最近更新 更多