我的手机上安装了 Playstore 应用程序!我想使用同一项目的调试 APK 来调试该移动应用程序。有什么方法可以调试该应用程序吗? 我不想卸载现有的数据应用程序。现在,当我尝试通过 Playstore APK 安装调试 APK 时遇到签名错误。
最佳答案
如果您需要在设备上安装同时 PlayStore apk 和您的Debug Apk,您可以使用构建类型applicationIdSuffix,如下所示
将此添加到您的app 级别 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"
当您构建 debug apk 并从 android studio 安装它时,它将附加 .debug
在您现有的包名
例如
PlayStore 包名称:com.example.myapp
调试包名称:com.example.myapp.debug
通过这种方式,您可以在设备上保留两个版本,并根据需要调试您的 apk。
编辑 1
如果您使用带有 google-services.json 的 Google 服务,您可能会遇到以下错误
这是因为 google-services.json 需要匹配包名称,如果你想拥有多个应用程序风格,如 Debug 和 ,你需要有多个 google-services.json发布
The google-services.json file is generally placed in the app/ directory (at the root of the Android Studio app module). As of version 2.2.0 the plugin supports build type and product flavor specific JSON files. All of the following directory structures are valid:
// dogfood and release are build types.
app/
google-services.json
src/dogfood/google-services.json
src/release/google-services.json
...
关于android - 如何通过 Playstore APK 安装调试 ApK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51435437/