android - 如何通过 Playstore APK 安装调试 ApK
问题描述
我的手机上安装了 Playstore 应用程序!我想用同一个项目的调试 APK 来调试那个移动应用程序。有什么方法可以调试该应用程序?我不想卸载现有的数据应用程序。现在,当我尝试通过 Playstore APK 安装调试 APK 时出现签名错误。
解决方案
如果您需要在设备上同时安装PlayStore apk 和调试Apk,您可以使用构建类型applicationIdSuffix,如下所示
将此添加到您的应用级别build.gradle
android {
...
buildTypes {
debug {
applicationIdSuffix ".debug"
}
release {
// Change to true if you want to apply ProGuard minify
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
...
}
applicationIdSuffix ".debug"
当您构建调试 apk并从 android studio 安装它时使用它,它将附加.debug
在您现有的包名称上
例如
PlayStore 包名称:com.example.myapp
调试包名称:com.example.myapp.debug
通过这种方式,您可以将两个版本的 apk 保留在设备上,并根据需要调试您的 apk。
编辑 1
如果您将 Google 服务与google-services.json一起使用,您可能会遇到以下错误
这是因为 google-services.json 需要匹配包名称,并且如果您想拥有多个应用程序风格(例如Debug和Release ),则需要拥有多个 google-services.json
所以根据谷歌文档
google-services.json 文件一般放在 app/ 目录下(Android Studio 应用模块的根目录)。从 2.2.0 版开始,插件支持构建类型和产品风味特定的 JSON 文件。以下所有目录结构均有效:
// dogfood and release are build types.
app/
google-services.json
src/dogfood/google-services.json
src/release/google-services.json
...
推荐阅读
- android - 如何从包含合并标签的布局访问视图,该标签包含在另一个布局中?
- postmates - Postmate : 安排创建交付
- extjs - 在 Ext JS 中使用 FusionCharts
- php - 如何在 PHP 中设置标题位置?
- sql - 跨多个列查找唯一数据的随机样本 - SQL Server
- javascript - CSS 类顺序对性能有影响吗?
- javascript - Javascript 函数 Object.keys 无法正常工作
- python - Pygame:图像没有出现在移动的背景上
- java - JPA 查询格式日期
- reactjs - 是否可以将 React 应用程序配置为在 Kubernetes 中使用容器的环境变量?