1

Hi I'm using gradle catalog feature (libs.versions.toml) . this is OK , but when I want to use multiple module in my android project I have an error in build.gradle .

My config :

libs.version.toml

[versions]
gradleplugin = "7.4.0-alpha09"
kotlin = "1.6.21"
room = "2.4.2"
compose = "1.3.0-beta01"


[libraries]
room-ktx           = { module = "androidx.room:room-ktx", version.ref = "room" }
room-paging        = { module = "androidx.room:room-paging", version.ref = "room" }
room-runtime       = { module = "androidx.room:room-runtime", version.ref = "room" }
room-compiler      = { module = "androidx.room:room-compiler", version.ref = "room" }
compose-activity   = "androidx.activity:activity-compose:1.5.1"
compose-material   = "androidx.compose.material3:material3:1.0.0-beta01"
compose-ui         = { module = "androidx.compose.ui:ui" , version.ref = "compose"}
compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling-preview" , version.ref = "compose"}
gson          = "com.google.code.gson:gson:2.9.0"
core-ktx      = "androidx.core:core-ktx:1.8.0"
runtime-ktx   = "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1"
test-juint = "androidx.test.ext:junit:1.1.3"
test-espresso =  "androidx.test.espresso:espresso-core:3.4.0"
test-compose-juint = {module = "androidx.compose.ui:ui-test-junit4" , version.ref = "compose" }
test-juint-core = "junit:junit:4.13.2"
test-compose-ui-tooling = {module = "androidx.compose.ui:ui-tooling" , version.ref = "compose"}
test-compose-ui-manifest = {module = "androidx.compose.ui:ui-test-manifest" , version.ref = "compose"}

[bundles]
room = ["room-ktx", "room-paging", "room-runtime"]
compose = ["compose-activity" , "compose-material" , "compose-ui" , "compose-ui-tooling"]
test-android = ["test-juint" , "test-espresso" , "test-compose-juint"]
test  = ["test-juint-core"]
debug = ["test-compose.ui-tooling" , "test-compose-ui-manifest"]

[plugins]
android-application = { id = "com.android.application", version.ref = "gradleplugin" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }

settings.gradle

pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}
rootProject.name = "My Application"
include ':app'
include ':feature:stage'

gradle-wrapper.properties

#Sat Aug 27 14:06:00 IRDT 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

build.gradle (:feature:stage)

plugins {
    alias(libs.plugins.android.application)  apply false
    alias(libs.plugins.kotlin.android) apply false
}

android {
    namespace 'com.malek.app.dsm.stage'
    compileSdk 33

    defaultConfig {
        minSdk 24
        targetSdk 33

        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_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

And when I want to create a new module in the corresponding window, a message is shown

New Module will not use Version catalog information

build.gradle message error :

Build file 'C:\dev\workspace\android\feature\stage\build.gradle' line: 6

A problem occurred evaluating project ':feature:stage'.
> Could not find method android() for arguments [build_74ujjxctpngqx1up1meon6fyc$_run_closure1@3e267557] on project ':feature:stage' of type org.gradle.api.Project.

1 Answers1

0

Just Remove " apply false " :

alias(libs.plugins.android.application)  apply false
alias(libs.plugins.kotlin.android) apply false

Fixed

alias(libs.plugins.android.application)   
alias(libs.plugins.kotlin.android)