复合构建在 Android 上损坏了还是我做错了?

问题描述 投票:0回答:2

在 10 分钟内,我在这个 git 存储库中创建了一个空的 android 库和一个空的 android 应用程序

https://github.com/deanhiller/compositeAndroid

如我的最后提交所示,我通过 gradle 出色的复合构建功能快速转换依赖于库的 Android 应用程序(我们在 monorepo 中大量使用此功能,因此加载项目会加载所有库源代码)它也使用)。我们的库由几个项目共享。

我进入compositeAndroid/MyApplication并运行./gradlew build,但失败了

* What went wrong:
Could not determine the dependencies of task ':app:mergeReleaseAssets'.
> Could not resolve all task dependencies for configuration ':app:releaseRuntimeClasspath'.
> Could not resolve com.tray.android:MyLib.
 Required by:
     project :app
  > No matching configuration of project :MyLib was found. The consumer was configured to find a runtime of a component, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.0' but:
      - None of the consumable configurations have attributes.

我不知道如何解决这个问题。我有一个解决办法来发布/使用,但更喜欢复合构建,因为它将库的源干净地引入 intellij 中。

为什么复合构建不起作用?我需要为 Android 项目做一些特别的事情吗?上面的仓库是我在 10 分钟内用这 2 个项目设置的(全新的)。

您也可以随时克隆并自己玩它。 (我们实际上将发布我们的 monorepo 开源模板,但它还不能很好地与 Android 配合使用)。

android-studio gradle android-gradle-plugin android-gradle-3.0
2个回答
0
投票

查看您在此处共享的存储库中

MyLib
文件夹下的代码后 - 看来您已经打开了一个常规项目并打算将其用作库

您能否按照此处所需的步骤在新模块下进行测试?

提示:您的构建应该会产生一个

aar
文件


0
投票

对于任何偶然发现这里的复合构建的人来说,Android 确实被破坏了。 我花了很多时间尝试调试,但没有成功,但从复合构建切换回多项目构建解决了这个问题(还有另一个问题:无法找到项目分解的aar

© www.soinside.com 2019 - 2024. All rights reserved.