简体   繁体   English

Gradle 将模块导入 Android 项目后构建失败

[英]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.

相关问题 导入模块后,Android 项目无法使用 gradle 构建 - Android project cannot build with gradle after importing a module Android-具有2个源文件夹的项目的Gradle构建失败 - Android - gradle build for project with 2 source folders fails 使用Jenkins构建android gradle项目失败 - Using Jenkins to build an android gradle project fails 安卓工作室。 build,gradle - 导入项目后找不到属性 - android studio. build,gradle - Could not find property, after importing project 在AndroidStudio中导入gradle项目失败 - Importing gradle project in AndroidStudio fails 将Google Play服务更新为8.1.0后,Android studio / Gradle项目无法构建 - Android studio/Gradle project fails to build after updating Google Play Services to 8.1.0 将项目导入Android Studio时,如何使自动Gradle构建静音? - How to silence automatic gradle build while importing a project to Android Studio? 从github导入Android Studio项目时发生Gradle构建错误 - Gradle build error when importing project of android studio from github 升级到Android Gradle Plugin 3.2后,Gradle构建中的Findbugs失败 - Findbugs in Gradle build fails after upgrading to Android Gradle Plugin 3.2 Android 主项目 build.gradle 中的插件部分和缺少的模块 - Plugins section in Android main project build.gradle and missing modules
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM