【问题标题】:How to add Fresco source into another project via Gradle如何通过 Gradle 将 Fresco 源代码添加到另一个项目中
【发布时间】:2018-02-23 18:17:20
【问题描述】:

我可以按照its own official site 的指示从源代码构建 Fresco。

但是我无法将其源代码作为项目添加到我的build.gradle

当尝试构建项目时,它会抛出如下异常:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':ReactAndroid'.
> Failed to notify project evaluation listener.
   > Could not resolve all dependencies for configuration ':ReactAndroid:_debugPublish'.
      > Configuration with name 'default' not found.
   > Could not resolve all dependencies for configuration ':ReactAndroid:compile'.
      > Configuration with name 'default' not found.

有没有机会克服这个问题?

settings.gradle 应用程序文件:

include ':app'

include ':fresco'
project(':fresco').projectDir = new File(rootProject.projectDir, '../fresco')

build.gradle 应用程序文件:

...
dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
        compile "com.android.support:appcompat-v7:27.0.+"

        compile project(':ReactAndroid')
        compile project(':fresco')
}
...

一些解释:

  • Fresco 有一个主要的 build.gradle 文件,用于服务于其他模块的 build.gradle 文件
  • 它还在自己的settings.gradle 文件中公开了许多模块。我不知道如何调用和使用它们。

【问题讨论】:

    标签: android gradle build build.gradle fresco


    【解决方案1】:

    您可以使用Gradle Composite builds 来实现这一点,这是 Gradle 3 中添加的一个功能。有很多方法可以配置它,但要包括本地构建的第三方库(如 fresco),您可以通过 cli 进行设置:

    ./gradlew assembleDebug --include-build <path/to/local/fresco/>

    由于它将项目分开,因此 fresco 构建的结构无关紧要,您无需修改​​ react 项目的 settings.gradlebuild.gradle。包含的构建将提供依赖并替换远程版本。

    【讨论】:

      猜你喜欢
      • 2021-11-12
      • 2021-08-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多