如何在Playstore上安装调试ApK APK

时间:2018-07-20 05:08:43

标签: android android-studio debugging testing adb

我的手机上安装了Playstore应用程序!我想使用同一项目的调试APK调试该移动应用程序。有什么方法可以调试该应用程序? 我不想卸载现有的数据应用程序。现在,当我尝试通过Playstore APK安装调试APK时遇到签名错误。

1 个答案:

答案 0 :(得分:1)

如果您需要在设备上安装两者 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'
        }
    }

    ...
}

在构建调试apk 并从android studio安装它时,使用此applicationIdSuffix ".debug"会将.debug附加到您现有的软件包名称上

例如

  • PlayStore程序包名称: com.example.myapp

  • 调试包名称: com.example.myapp.debug

通过这种方式,您可以保留设备上两个APK的版本,并根据需要调试您的APK。


编辑1

如果您将Google Services与 google-services.json 结合使用,则可能会遇到以下错误

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

这是因为google-services.json需要匹配软件包名称,并且如果要具有多种应用程序风格(如 Debug ),则需要具有多个google-services.json。释放

按照Google Documentation

  

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
    ...
相关问题