【问题标题】:Android Studio build configurations [duplicate]Android Studio 构建配置 [重复]
【发布时间】:2013-06-28 11:30:04
【问题描述】:

我想知道如何创建不同的构建配置,使用 Android Studio 为调试和发布构建提供不同的常量(例如,服务器地址、API 密钥……)。

【问题讨论】:

  • 这看起来不像是指定问题的重复。

标签: android configuration android-studio


【解决方案1】:

编辑模块中的build.gradle 文件并将以下任何内容添加到您的android{} 容器中。

    signingConfigs {
        release {
            storeFile file("path relative to the root of the project")
            storePassword "PASSWORD!"
            keyAlias "projectname"
            keyPassword "PASSWORD!"
        }
    }


    buildTypes {
        debug {
            versionNameSuffix "-DEBUG"
            packageNameSuffix ".debug"
        }
        release {
            debuggable false
            signingConfig signingConfigs.release
        }
        debugRelease.initWith(buildTypes.release)
        debugRelease {
            debuggable true
            packageNameSuffix '.debugrelease'
            signingConfig signingConfigs.release
        }
    }

}

这增加了 3 种构建类型(release、debugRelease 和 debug)

release 和 debugRelease 使用相同的键,并且 debugRelease 是 Release 的副本。

【讨论】:

  • 这不是我想要的,但足以为我指明正确的方向。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-03
  • 2023-03-05
  • 2018-05-20
  • 2017-10-06
  • 2019-08-12
  • 2019-04-17
相关资源
最近更新 更多