android - 如何根据构建风格禁用 Google 的应用内更新?
问题描述
我正在尝试实现谷歌的应用内更新。当试图直接从 AndroidStudio 运行应用程序时,我得到了这个异常:
com.google.android.play.core.install.InstallException: Install Error(-10): The app is not owned by any user on this device. An app is "owned" if it has been acquired from Play. (https://developer.android.com/reference/com/google/android/play/core/install/model/InstallErrorCode#ERROR_APP_NOT_OWNED)
我了解当应用程序未从 Play 商店安装时,谷歌无法检查更新。我的目标是在应用程序处于未从 Play 商店安装的测试版本中时禁用此功能,因为在这些情况下,我无论如何都不关心应用程序更新。
如何根据构建风格禁用此检查?
我已经阅读了本指南,但它没有提到任何我想要的东西。
解决方案
只需app/build.gradle
为每种构建类型定义一些属性
buildTypes {
debug {
buildConfigField 'boolean', 'UPDATE_ENABLED', 'false'
}
release {
buildConfigField 'boolean', 'UPDATE_ENABLED', 'true'
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
同步后,您可以请求if(BuildConfig.UPDATE_ENABLED)
并检查更新
推荐阅读
- python - 如何理解字典项目比较?
- r - 使用 stargazer 输出汇总统计信息
- html - 单独段落行的背景颜色 - Css
- java - Spring ConfigurationProperties 问题
- scala - 使用 Avro 构建 Apache Spark 的问题
- php - 如何从网站向移动设备拨打 VOIP 电话?
- vb.net - 在 CE 窗体(Windows 窗体)内启动应用程序/游戏
- javascript - 将字符串中给定索引处的字母变为大写
- javascript - 指示内容 jquery 表上的顶部标题
- java - 如何将实时音频流拆分为单独的通道并保存到文件?