Why is this gradle error showing up when trying to reuse Android archive in another Android app?

Viewed 116

I'm reusing an Android module from one app to another by building the aar and importing into the second app in 'app/src/main/libs' based on what I could understand from documentation and information on forums.

// Top-level build.gradle file 
buildscript {
    repositories {
        jcenter()
        google()
        }
    }
allprojects {
    repositories {
        jcenter()
        google()
        flatDir{
            dirs 'src/main/libs'
        }
    }
}

//build.gradle(:app)
dependencies {
        implementation files('src/main/libs/mercuryHw-debug.aar')
    }

But when I try to: ./gradlew build

I see this error: FAILURE: Build failed with an exception.

  • Where: Build file '/home/popossri/ArcX/mercury_files/manifest/jenkins/Android/external/mercury/apps/multitouch-android/app/build.gradle' line: 2

  • What went wrong: A problem occurred evaluating project ':app'.

Could not find method implementation() for arguments [file collection] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

I have already upgraded to latest gradle v7.2. What am I missing here?

1 Answers

Miss plugins in the head of build.gradle file :

plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

,,,,

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar","*.aar"])
}
Related