Search code examples
androidgradlebuild.gradlemulti-moduleagora.io

Gradle Build fails after importing modules into Android project


I am trying to import the Agora.IO modules from here to implement a screen sharing functionality. After cloning the repository at the provided link and adding it as a Module for my project, I am able to get all the imports correctly. The only imports that I needed were import io.agora.api.*, but the build fails with the following message.

Execution failed for task ':lib-switch-external-video:compileDebugAidl'.
> Could not resolve all files for configuration ':lib-switch-external-video:debugCompileClasspath'.
> Could not find com.github.agorabuilder:native-full-sdk:3.4.2.
 Required by:
     project :lib-switch-external-video > project :lib-component

Possible solution:
- Declare repository providing the artifact, see the documentation at 
https://docs.gradle.org/current/userguide/declaring_repositories.html

This is how my project strucure looks after importing the modules:

enter image description here

Though I'm not much experienced with multi-module apps yet, but I have added these to my settings.gradle file already:

settings.gradle

rootProject.name = "dummy"
include ':app'
include ':lib-push-externalvideo'
include ':lib-screensharing'
include ':lib-player-helper'
include ':lib-stream-encrypt'
include ':lib-component'
include ':lib-raw-data'
include ':lib-switch-external-video'

inside the default build.gradle of lib-component module I found

api 'com.github.agorabuilder:native-full-sdk:3.4.2'
api 'io.agora:agoraplayer:1.2.4'

Inside the build.gradle of each of these modules there is already either of these added:

implementation project(path: ':lib-component')
or
api project(path: ':lib-component')

The only reason why I chose importing those modules is because I wasn't able to find the gradle dependency that had support for these imports. If there is such a dependency, please let me know about it!


Solution

  • The issue is exactly mentioned in the message. Gradle cannot resolve com.github.agorabuilder:native-full-sdk:3.4.2 dependency in any of the repositories that were added in the module.

    Did you have jitpack repo defined there?

    repositories {
        maven { url 'https://www.jitpack.io' }
        
        // Other repositories you need
    }
    

    Also, separate from your issue, your settings.gradle file seems a bit different. I assume that you've copied all the source code into your project.

    Instead, I'd choose to link them instead of copying the sources in this case. For that, you can use

    include ':lib-component'
    project(':lib-component').projectDir = new File('/path/to/cloned/repo/lib-component/')
    

    Prefer this when you're debugging a library which you appear to be. This way, you add that exact module in this build, and making any changes here will actually happen in that project. Allows you to simply commit or change branches in that repo.