Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find method namespace() for arguments [com.android.mylib] on extension 'android' of type com.android.build.gradle.LibraryExtension

I am trying to create a library in android studio by following this official documentation. But in this particular project, I am facing this issue. if I create new project and create new lib I don't face any issue. It means something is wrong with this project only.

My Lib Gradle

plugins { id 'com.android.library' }

android {
    namespace 'com.android.mylib'
    compileSdkVersion 33

defaultConfig {
    minSdkVersion 26
    targetSdkVersion 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
}

}

App Gradle

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

android {
    compileSdkVersion 33
    buildToolsVersion "30.0.2"
    testBuildType "beta"

    defaultConfig {
        applicationId "com.app.etc"
        minSdkVersion 23
        targetSdkVersion 33
        versionCode 327

I have searched some questions, but according to those answers, everything seems correct. i have invalidated cache and restarted the android studio as well.

Here is the error.

 A problem occurred evaluating project ':mylibrary'

Caused by: 

org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method namespace() for arguments [com.example.mylibrary] on extension 'android' of type com.android.build.gradle.LibraryExtension.

like image 925
Ifan 767 Avatar asked Dec 18 '25 16:12

Ifan 767


1 Answers

That is the problem with the Gradle version used in the app some plugins want latest version of the Gradle

Try to change the Gradle version in:

  1. android/gradle/gradle-wrapper-properties file change the gradle version distributionUrl=https://services.gradle.org/distributions/gradle-7.5-all.zip
  2. android/build.gradle file Under dependencies change the following line to use the latest gradle version classpath 'com.android.tools.build:gradle:7.5.2'
like image 70
Firooz Smart Avatar answered Dec 21 '25 22:12

Firooz Smart



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!