android-sdk icon indicating copy to clipboard operation
android-sdk copied to clipboard

[Spotify App Remote] Direct local .aar file dependencies are not supported when building an AAR

Open Volatile-Memory opened this issue 4 years ago • 8 comments

I am building a modular application that makes use of gradle android submodules.

One of the submodules is specific to Spotify and thus it depends on

    implementation files("libs/spotify/app-remote-lib/spotify-app-remote-release-0.7.0.aar")
    implementation "com.spotify.android:auth:1.2.3"

Does the spotify-app-remote library have a gradle repo that hosts it like there is for the "com.spotify.android:auth" one? Whenever I try to build my app with the direct dependency on the spotify-app-remote-release-0.7.0.aar, I get this error from gradle:

Direct local .aar file dependencies are not supported when building an AAR. 
The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. 
Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error). 
The following direct local .aar file dependencies of the :spotify project caused this error: ../StudioProjects/Kit/spotify/libs/spotify/app-remote-lib/spotify-app-remote-release-0.7.0.aar

Volatile-Memory avatar Aug 30 '20 15:08 Volatile-Memory

api fileTree(dir: "libs", include: ['*.jar', '*.aar'])

ChinaVolvocars avatar Sep 25 '20 07:09 ChinaVolvocars

USE '' NOT ""

ChinaVolvocars avatar Sep 25 '20 07:09 ChinaVolvocars

USE '' NOT ""

?

Volatile-Memory avatar Sep 25 '20 07:09 Volatile-Memory

I am also interested in a Maven dependency instead of a bundled AAR file. The Android ecosystem uses Maven to organize dependencies and to help keep libraries updated, instead of manually including a binary blob in the project.

hufman avatar Oct 18 '20 15:10 hufman

What a coincidence, I am trying a similar thing too. I am currently attempting to build an AAR plugin for Unity 3D with this Spotify Android SDK. I have gotten through your issue by using "compileOnly files('libs/spotify-app-remote-release-0.7.1.aar')" in the dependencies instead of "implementation files("libs/spotify/app-remote-lib/spotify-app-remote-release-0.7.1.aar")" (Notice the file name, we might be using different versions of the remote library) But even after this and I got my plugin to compile, i'm still getting an ERROR called : "Call Exception: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/spotify/android/appremote/api/ConnectionParams$Builder;" When I try to use it. Try out the solution i just mentioned, it might solve the problem you are currently facing and let me know if it works/if you manage to get the SDK to behave like its supposed to.

benlane2003 avatar Nov 02 '20 14:11 benlane2003

I have exactly the same problem when I follow the Spotify documentation to the letter.

In Android Studio, the Spotify SDK is well recognized because I can use the SDK's features, but as soon as the application launches and uses ConnectionParams.Builder, I get the error

"Call Exception: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/spotify/android/appremote/api/ConnectionParams$Builder;"

NicolasLaurentGarnotel avatar Jan 07 '21 12:01 NicolasLaurentGarnotel

What a coincidence, I am trying a similar thing too. I am currently attempting to build an AAR plugin for Unity 3D with this Spotify Android SDK. I have gotten through your issue by using "compileOnly files('libs/spotify-app-remote-release-0.7.1.aar')" in the dependencies instead of "implementation files("libs/spotify/app-remote-lib/spotify-app-remote-release-0.7.1.aar")" (Notice the file name, we might be using different versions of the remote library) But even after this and I got my plugin to compile, i'm still getting an ERROR called : "Call Exception: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/spotify/android/appremote/api/ConnectionParams$Builder;" When I try to use it. Try out the solution i just mentioned, it might solve the problem you are currently facing and let me know if it works/if you manage to get the SDK to behave like its supposed to.

Thats because compileOnly does not support aar files. Source: https://developer.android.com/studio/build/dependencies

I'm basically stuck as well (but for another project, unrelated to spotify).

larssn avatar Mar 30 '21 09:03 larssn

How easy/hard is it to add the remote sdk to a maven repository?

brim-borium avatar May 11 '21 07:05 brim-borium