不可能在另一个模块中使用一个模块的资源

问题描述 投票:0回答:1

我的应用程序中有两个模块:应用程序和管理。我需要在管理模块中使用应用程序模块的一些功能,但是,当我尝试访问我尝试引用的文件时,会出现以下错误:将模块“ace-mobile.app.main”添加到依赖项模块“ace-mobile.destao”。 main' 并导入未解析的类。

我已经在管理模块中添加了app模块的依赖。当我执行相反的操作(将管理模块引用放入应用程序中)时,它可以正常工作。

enter image description here

应用程序模块的build.gradle:

    apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'dagger.hilt.android.plugin'

android {
    namespace 'horizon.maeandroid'
    compileSdk 34

    defaultConfig {
        applicationId "horizon.maeandroid"
        minSdkVersion 23
        targetSdkVersion 30
        versionCode 281
        versionName "7.2.19"
        multiDexEnabled true
        setProperty("archivesBaseName", "ace_" + versionName)

        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["dagger.hilt.android.module.withPackageName": "horizon.maeandroid.app"]
            }
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            resValue("string", "DNS_SENTRY", '""')
        }

        debug {
            resValue("string", "DNS_SENTRY", '""')
        }
    }

    viewBinding {
        enabled = true
    }

    flavorDimensions "version"
    productFlavors {
        beta {
            dimension "version"
            applicationIdSuffix ".beta"
            versionNameSuffix "-beta"
            buildConfigField("String", "CLIENTES_URI", '"clientes?ativo"')
        }
        production {
            dimension "version"
            buildConfigField("String", "CLIENTES_URI", '"clientes?ativo&producao"')
        }
        goiania {
            dimension "version"
            buildConfigField("String", "CLIENTES_URI", '"clientes?ativo&producao"')
        }
    }
}

dependencies {
    implementation('com.mikepenz:materialdrawer:6.1.3@aar') {
        transitive = true
    }
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'com.android.volley:volley:1.2.1'
    implementation 'com.github.bumptech.glide:glide:4.14.1'
    implementation 'com.github.lecho:hellocharts-android:1.5.8'
    implementation 'com.google.code.gson:gson:2.10'
    implementation 'com.google.android.material:material:1.6.1'
    implementation 'com.google.android.gms:play-services-location:17.1.0'
    implementation 'com.mikepenz:google-material-typeface:2.2.0.3.original@aar'
    implementation 'com.jakewharton:butterknife:10.2.3'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'
    implementation 'io.sentry:sentry-android:5.5.1'
    implementation 'com.yarolegovich:lovely-dialog:1.1.1'
    implementation 'com.google.android.flexbox:flexbox:3.0.0'
    implementation "com.google.dagger:hilt-android:2.44"
    annotationProcessor 'com.google.dagger:hilt-android-compiler:2.44'

}

gestao模块的build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'dagger.hilt.android.plugin'

android {
    namespace 'horizon.maeandroid.gestao'
    compileSdk 34

    defaultConfig {
        applicationId "horizon.maeandroid"
        minSdk 23
        targetSdk 30
        versionCode 281
        versionName "7.2.19"
        multiDexEnabled true
        setProperty("archivesBaseName", "ace_" + versionName)

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["dagger.hilt.android.module.withPackageName": "horizon.maeandroid.gestao"]
            }
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    viewBinding {
        enabled = true
    }
}

 dependencies {

    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.12.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
    implementation "com.google.dagger:hilt-android:2.44"
    annotationProcessor 'com.google.dagger:hilt-android-compiler:2.44'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'com.google.code.gson:gson:2.10'

    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'com.android.volley:volley:1.2.1'
    implementation 'com.github.bumptech.glide:glide:4.14.1'
    implementation 'com.github.lecho:hellocharts-android:1.5.8'
    implementation 'com.google.code.gson:gson:2.10'
    implementation 'com.google.android.material:material:1.6.1'
    implementation 'com.google.android.gms:play-services-location:17.1.0'
    implementation 'com.mikepenz:google-material-typeface:2.2.0.3.original@aar'
    implementation 'com.jakewharton:butterknife:10.2.3'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'
    implementation 'io.sentry:sentry-android:5.5.1'
    implementation 'com.yarolegovich:lovely-dialog:1.1.1'
    implementation 'com.google.android.flexbox:flexbox:3.0.0'

    implementation project(':app')
}

我尝试检查 gradle 中的语法,但没有发现任何错误。

android android-module
1个回答
0
投票

我刚刚创建了一个空应用程序,带有两个模块。

app - 它是一个主要的应用程序模块。 管理 - 这是第二个模块。

我在管理项目中添加了依赖:

implementation(project(":app"))

应用程序模块中的资源变得可用

但是当我尝试在应用程序模块中添加依赖项以使用管理模块中的资源时,我收到了警报:

“添加对模块的依赖 'AppForTestingErrorsInStackOwerflow.management.main' 将引入 模块之间的循环依赖 'AppForTestingErrorsInStackOwerflow.app.main' 和 'AppForTestingErrorsInStackOwerflow.management.main'。添加依赖项 无论如何?”

我按了“确定”,添加了依赖项,但现在应用程序无法构建。 也许这是你的问题?

© www.soinside.com 2019 - 2024. All rights reserved.