Add an AAR dependency in Android Studio 4.2

Viewed 274

I'm trying to use https://github.com/brim-borium/spotify_sdk in Android Studio with Flutter

As such, I need to import Spotify SDK (two AAR files), and to be able to add them to the build process.

Because of spotify_sdk (flutter package), I can't use (which seem to work)

implementation (name: 'spotify-app-remote', ext: 'aar')
implementation (name: 'spotify-auth', ext: 'aar')

in my project, I specifically need Gradle to consider spotify-app-remote & spotify-auth as projects, because spotify_sdk imports them like this.

implementation project(':spotify-auth')
implementation project(':spotify-app-remote')

Here is the Gradle error:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
   > Could not resolve project :spotify-auth.
     Required by:
         project :app
      > No matching configuration of project :spotify-auth was found. The consumer was configured to find an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but:
          - None of the consumable configurations have attributes.
   > Could not resolve project :spotify-app-remote.
     Required by:
         project :app
      > No matching configuration of project :spotify-app-remote was found. The consumer was configured to find an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but:
          - None of the consumable configurations have attributes.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
Exception: Gradle task assembleDebug failed with exit code 1

Here is my settings.gradle


def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"

So I need to be able to force Gradle to import these AAR as a projet.

Here is my project structure, if it useful Project Structure

From documentation and StackOverflow posts, I've read that Android Studio used to have an Import AAR/Jar file functionality. It is now missing in Android Studio 4.2

Is there any functionality that replaces Import AAR/Jar file? Or any way to force Gradle to recognize these files as projects?

Thank you very much

0 Answers
Related