【问题标题】:How to convert android studio app project into an android library如何将 android studio 应用程序项目转换为 android 库
【发布时间】:2019-05-29 02:26:28
【问题描述】:

我想将现有的 android studio 应用项目转换为一个 android 库,并将其作为依赖项添加到新的 android studio 应用项目中。

android studio 应用项目具有三个 android 库项目作为依赖项以及 firebase 和 Crashlytics 集成,

现在我想将整个项目转换为一个 android 库并将其添加到另一个 android studio 应用程序项目中。

我已尝试更改以下行

//from
apply plugin: 'com.android.application'
//to
apply plugin: 'com.android.library'

android 库包含 google-services.json 和其他 API 密钥。因此,当我将 android 库添加为新应用程序项目的依赖项时,它只会从 android 库中获取模块,而不是 google-services.json 和其他设置

如何解决这个问题,或者有另一个过程将应用程序项目转换为库

【问题讨论】:

  • 您能告诉我们您遇到了什么错误吗?您可能需要将一些依赖项转移到您的新应用项目中。
  • 新的应用项目将用于第三方,android 库包含 google-services.json 和其他 API 密钥。因此,当我将 android 库作为依赖项添加到第三方应用程序项目时,它只会从 android 库中获取模块,而不是 google-services.json 和其他设置
  • Firebase 仅适用于应用程序模块,不适用于库模块。因此,每个项目将只包含一个google-services.json 文件,它不属于该库。
  • 处理这种情况的任何解决方案,如何将整个 android studio 应用程序项目转换为 android 库。
  • 1.让想要集成该库的公司创建一个 Firebase 项目并将google-services.json 文件添加到他们的项目中,以便他们可以使用您的库。 2. 从库中删除 Firebase,并为您依赖 Firebase 的功能寻找替代品。

标签: android android-studio android-gradle-plugin dependencies gradlew


【解决方案1】:

您可以在代码端使用 google-service.json 中的值初始化 Firebase。这样您就可以摆脱 google-service.json 文件。

【讨论】:

    猜你喜欢
    • 2022-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-10
    • 2013-07-10
    • 1970-01-01
    • 1970-01-01
    • 2016-12-26
    相关资源
    最近更新 更多