简体   繁体   English

如何调试从Play商店安装的APK(不删除已保存的用户数据)

[英]How to debug an APK installed from Play Store (without deleting saved user data)

The Problem 问题

I am working with an Android app where user data is being saved to a database encrypted by SQLCipher. 我正在使用Android应用程序将用户数据保存到由SQLCipher加密的数据库中。 The Android keystore is being used to store the keys. Android密钥库用于存储密钥。 There is a device specific issue happening (likely to do with the data that is being saved). 存在特定于设备的问题(可能与正在保存的数据有关)。 I can potentially get my hands on the device that is experiencing this issue, however, from what I can find, the info I can extract from the said device is very limited. 我可能会遇到遇到此问题的设备,但是,从我能找到的信息中,我可以从所述设备中提取的信息非常有限。 Is there any possible way I can somehow attach a debugger to the current APK that is loaded onto the device or somehow replace it with a debuggable version without losing the user data? 是否有任何可能的方法我可以以某种方式将调试器附加到当前加载到设备上的APK或以某种方式用可调试版本替换它而不丢失用户数据?

The device is running android 6.0.1 and I am using Android Studio 该设备运行Android 6.0.1,我正在使用Android Studio

What I found trying to debug the release APK 我发现试图调试发布APK

When I connect an android tablet loaded with the APK that was downloaded from the PlayStore, the only data I am able to see are the app specific debug logs using logcat (Android Studio). 当我连接加载了从PlayStore下载的APK的Android平板电脑时,我能够看到的唯一数据是使用logcat(Android Studio)的应用特定调试日志。 When I try to debug the app, Android Studio is telling me to uninstall the existing APK first before I can load the debuggable APK. 当我尝试调试应用程序时,Android Studio告诉我先卸载现有的APK,然后才能加载可调试的APK。 However, this will delete existing data, which I do not want to happen. 但是,这将删除我不希望发生的现有数据。

Other things I have tried to solve my original problem 我试图解决原始问题的其他事情

Try to get the specific user to send me their problematic database 尝试让特定用户向我发送有问题的数据库

This won't work as I don't have access to the private key, so I would not be able to decrypt the data even if I got the file. 这不起作用,因为我无法访问私钥,所以即使我拿到了文件,也无法解密数据。

Try to get specific user to send me the app logs 尝试让特定用户向我发送应用程序日志

This won't work as since Android 4.1, app specific logs are private to only those specific apps (unless the device is rooted, which the device in question is not, and rooting it is not really an option). 这不起作用,因为Android 4.1,特定于应用程序的日志仅对那些特定应用程序是私有的(除非设备已植根,有问题的设备不是,并且根本不是一个选项)。 This actually leads to another, lightly related, question I have. 这实际上导致了另一个轻微相关的问题。 Why am I able to see the application specific logs in logcat even though they are not visible when view logs on an unrooted device through an app such as CatLog? 为什么我能够在logcat中看到特定于应用程序的日志,即使它们在通过诸如CatLog之类的应用程序登录无根设备时不可见?

You can install a debuggable APK by simply signing with your release keys instead of the debug ones and making sure the Debug flag is set. 您可以通过简单地使用发行密钥而不是调试密钥进行签名来安装可调试的APK,并确保设置了Debug标志。 I always do this as it becomes a pain to keep uninstalling and reinstalling different versions especially when swapping between different computers with different debug keystores. 我总是这样做,因为继续卸载和重新安装不同版本变得很痛苦,尤其是在使用不同调试密钥库的不同计算机之间进行交换时。

Installing an APK signed with your release keys will just perform an in place upgrade and leave all app data intact even if the debuggable flag is set. 安装使用您的发布密钥签名的APK只会执行就地升级,即使设置了debuggable标志,也会保留所有应用程序数据。

eg 例如

 buildTypes {

    debug {
        minifyEnabled false
        debuggable true
        signingConfig signingConfigs.release
    }

    release {
        minifyEnabled false
        signingConfig signingConfigs.release
    }

}

You can get logs from a user device so long as the log was generated by your own app. 只要日志是由您自己的应用程序生成的,您就可以从用户设备获取日志。 Your own process is allowed to access your own apps log entries. 您自己的进程可以访问您自己的应用程序日志条目。

Read logcat programmatically within application 在应用程序中以编程方式读取logcat

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在从Play商店安装的版本之上安装Android调试版本或发布版本,并保留数据? - How to install Android debug or release build on top of build installed from Play Store and keep data? 如果用户通过邀请链接安装,如何跟踪来自 android Play 商店的数据 - How to track data from android play store if user installed from invite link Android:安装APK后从Play商店重定向到Android应用 - Android: Redirect to android app from play store when apk is installed 从Play商店在设备上安装了错误的APK - Wrong apk getting installed on devices from play store APK 版本未从 Play 商店更新已安装的 AAB 应用 - APK release not update installed AAB app from Play Store 已安装的APK无法在本地或Play商店上使用 - Installed APK not working locally or on Play store 手动安装时 APK 文件运行正常,但从 Google Play 商店安装时无法打开 - APK file runs properly when installed manually but does not open when installed from google play store 如何在没有 Play 商店的情况下将生成的 apk 部署到 Wear OS 设备 - How to deploy a generated apk to a Wear OS device without Play Store 调试 apk 大小是否大于 google play store 中的相同 apk - Is debug apk size is greater than same apk in google play store 在没有Google Play的情况下使用另一个APK更新已安装的Android APK - Update an installed android apk using another apk without google play
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM