构建错误。配置了依赖性功能,但没有设置软件包ID

0 人关注

我的安卓项目有两个应用模块(即应用程序和用户模块)。我可以在它们之间建立依赖关系吗?

当我通过添加 "implementation project(path: ':user') "来构建应用程序时,它提示我如帖子标题那样的错误信息。

我发现我可以把模块改为 "库"。目前,我更喜欢使用应用程序

build.gradle(app)

plugins {
    id 'com.android.application'
android {
    compileSdk 31
    defaultConfig {
        applicationId "com.app.myapp"
        minSdk 28
        targetSdk 31
        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_11
        targetCompatibility JavaVersion.VERSION_11
dependencies {
    implementation 'androidx.appcompat:appcompat:1.4.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
    implementation project(path: ':user')

build.gradle(用户)

plugins {
    id 'com.android.application'
android {
    compileSdk 31
    defaultConfig {
        minSdk 28
        targetSdk 31
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    buildFeatures {
        viewBinding true
        dataBinding true
dependencies {
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.6.0'
    implementation 'androidx.navigation:navigation-fragment:2.4.2'
    implementation 'androidx.navigation:navigation-ui:2.4.2'
    testImplementation 'junit:junit:4.13.2'