[英]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.我正在尝试从此处导入
Agora.IO
模块以实现屏幕共享功能。 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.在提供的链接上克隆存储库并将其添加为我的项目的
Module
后,我能够正确获取所有imports
。 The only imports that I needed were import io.agora.api.*
, but the build fails with the following message.我需要的唯一导入是
import io.agora.api.*
,但构建失败并显示以下消息。
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:
这是我的项目结构在导入模块后的样子:
Though I'm not much experienced with multi-module
apps yet, but I have added these to my settings.gradle
file already:虽然我对
multi-module
应用程序的经验还不多,但我已经将这些添加到我的settings.gradle
文件中:
settings.gradle
设置.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在我发现的
lib-component
模块的默认build.gradle
里面
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:在每个模块的
build.gradle
内,已经添加了以下任一模块:
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.我选择导入这些模块的唯一原因是因为我找不到支持这些导入的
gradle
依赖项。 If there is such a dependency, please let me know about it!如果有这样的依赖,请告诉我!
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. Gradle 无法解析
com.github.agorabuilder:native-full-sdk:3.4.2
在添加到模块中的任何存储库中的依赖项。
Did you have jitpack repo defined there?你在那里定义了 jitpack repo 吗?
repositories {
maven { url 'https://www.jitpack.io' }
// Other repositories you need
}
Also, separate from your issue, your settings.gradle file seems a bit different.此外,与您的问题不同,您的 settings.gradle 文件似乎有点不同。 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.
允许您简单地提交或更改该 repo 中的分支。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.