gpt4 book ai didi

android - 如何通过 Playstore APK 安装调试 ApK

转载 作者:行者123 更新时间:2023-11-28 20:36:47 24 4
gpt4 key购买 nike

我的手机上安装了 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 服务,您可能会遇到以下错误

  • 错误:任务“:app:processDebugGoogleServices”执行失败。 - Solution
  • 找不到与包名称匹配的客户端 - Solution

这是因为 google-services.json 需要匹配包名称,如果你想拥有多个应用程序风格,如 Debug,你需要有多个 google-services.json发布

根据Google Documentation

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com