错误的构建变体
Wrong build variant
我的应用程序中有 2 个模块,一个用于 API,一个用于应用程序。
在 API 模块中,我定义了 2 个 API 端点,具体取决于 API 是在 debug
还是 release
模式下编译:
buildTypes {
all {
buildConfigField "String", "API_DEVICE_TYPE", "\"android-phone\""
}
debug {
buildConfigField "String", "API_ENDPOINT", "\"https://beta-api.company.com/\""
}
release {
buildConfigField "String", "API_ENDPOINT", "\"https://api.company.com/\""
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
在 Android Studio 的 Build variant
面板中,我为应用程序和 API 模块选择了调试变体。但是当我按 hand/resync gradle 按下 play/clean/rebuild/remove 所有构建目录时,无论我做什么,这都是每次编译的版本 API。
有什么提示吗?
尝试使用 gradle 构建工具 2.1.0
和 2.2.0-aplha3
。
只需将此代码添加到您的子模块中即可 build.gradle
// There is a limitation in gradle: You can't pick what submodule of app you want to compile your app with.
// This attribut define which build variant you want your api to be compiled against.
// https://sites.google.com/a/android.com/tools/tech-docs/new-build-system/user-guide#TOC-Library-Publication
defaultPublishConfig "debug"
我的应用程序中有 2 个模块,一个用于 API,一个用于应用程序。
在 API 模块中,我定义了 2 个 API 端点,具体取决于 API 是在 debug
还是 release
模式下编译:
buildTypes {
all {
buildConfigField "String", "API_DEVICE_TYPE", "\"android-phone\""
}
debug {
buildConfigField "String", "API_ENDPOINT", "\"https://beta-api.company.com/\""
}
release {
buildConfigField "String", "API_ENDPOINT", "\"https://api.company.com/\""
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
在 Android Studio 的 Build variant
面板中,我为应用程序和 API 模块选择了调试变体。但是当我按 hand/resync gradle 按下 play/clean/rebuild/remove 所有构建目录时,无论我做什么,这都是每次编译的版本 API。
有什么提示吗?
尝试使用 gradle 构建工具 2.1.0
和 2.2.0-aplha3
。
只需将此代码添加到您的子模块中即可 build.gradle
// There is a limitation in gradle: You can't pick what submodule of app you want to compile your app with.
// This attribut define which build variant you want your api to be compiled against.
// https://sites.google.com/a/android.com/tools/tech-docs/new-build-system/user-guide#TOC-Library-Publication
defaultPublishConfig "debug"