如何在USB连接的设备上的Android Studio中调试应用程序升级 [英] How to debug an app upgrade in Android Studio on a USB connected device

查看:316
本文介绍了如何在USB连接的设备上的Android Studio中调试应用程序升级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在手机上发布了Google Play商店应用的正式版,并在Android Studio中拥有了该应用的更新版本. 我想测试升级过程,但是遇到版本问题,然后是日志记录问题.

I have the production release of my Google Play Store app on my phone and have an updated version of the app in Android Studio. I would like to test the upgrade process, but have run into a versioning problem, then a logging problem.

要进行全新"安装,我可以进入手机的设置Backup & reset > Automatic restore,将其关闭,然后重新安装该应用程序,然后从Play商店安装它.或者,我可以下载正式版APK并从adb命令行安装(详细信息如下).结果是我的设备应与普通生产用户相同.

To get a "clean" install, I can go into my phone's settings Backup & reset > Automatic restore, turn that off, then de-install the app, and install it from the Play Store. Alternatively, I could download the production APK and install it from the adb command line (details below). The result is my device should be the same as a regular production user.

与问题没有直接关系,但要了解我观看升级过程的动机是该应用程序具有SQLite数据库,并且我扩展了SQLiteOpenHelper,因此调用了onUpgrade(),并且正在完成一些数据库架构工作.

Not directly germane to the question, but to understand my motivation for watching the upgrade process is that the app has an SQLite database and I extend SQLiteOpenHelper, so onUpgrade() is called, and some database schema work is being done.

如果我单击按钮以部署该应用程序,然后选择我已连接的设备,则该设备要先卸载,然后再继续:

If I click the button to deploy the app, then select my connected device, it wants to uninstall before proceeding:

安装失败,并显示消息无法完成会话:INSTALL_FAILED_UPDATE_INCOMPATIBLE

Installation failed with message Failed to finalize session : INSTALL_FAILED_UPDATE_INCOMPATIBLE

很明显,我可以卸载,但是这不会测试升级过程!

Obviously I could uninstall, but that would not test the upgrade process!

我使用Generate Signed APK...构建了一个发行" APK,与生成要上传到Play商店的发行时所使用的过程相同.这可以解决版本控制问题,但会导致日志记录可见性问题.过去和现在使用的发行版配置如下所示:

I built a "release" APK, using Generate Signed APK..., which is the same process I use when generating a release for uploading to the Play Store. This gets around the versioning problem, but causes a logging visibility problem. The release configuration used in the past and now looks like this:

"C:\ Program Files(x86)\ HTC \ HTC Sync Manager \ HTC Sync \ adb" install -r app-release.apk

"C:\Program Files (x86)\HTC\HTC Sync Manager\HTC Sync\adb" install -r app-release.apk

以上完成的升级没有卸载.我使用的过程是在Android Studio中打开Terminal,将目录更改为存储生成的APK的目录,然后键入上述命令.

The above did upgrade without uninstalling. The process I used was to open Terminal within Android Studio, change directory to where the generated APK was stored, then type the above command.

adb命令行触发了升级过程,但没有立即开始向Logcat窗口提供调试信息.我可以为所有进程连接到Logcat,但是我无法仅获取进程的调试信息,也无法访问调试工具.

The adb command line triggered the upgrade process, but it did not start feeding the Logcat window immediately with debug information. I could connect to Logcat for all processes, but I could not get debug information for just my process, and did not have access to debugging tools.

我该如何从运行签名生产版本的设备开始,然后使Android Studio中包含的更新版本能够运行而无需卸载,并且能够在升级过程中查看调试输出?或者,如何修改签名的生产版本,使其可以更新新版本并允许调试?

How can I start with a device that's running a signed production release then cause an updated version, contained in Android Studio, to run, without uninstalling, and with the ability to see the debugging output during the upgrade process? Or how can I modify a signed production release such that it allows an new version to update and allow debugging?

推荐答案

因为您使用的是Debuggable=false的APK,因此您的解决方法包括使用与制作相同的过程来构建应用程序的更新发布过程,并获得具有所有过程的Logcat可能是您所能做的最好的事情.

Because you're starting with an APK that is Debuggable=false, your work-around that includes building an update to the app using the same process as your production release process and getting a Logcat with all processes is probably the best you can do.

一种选择是将特定版本的应用从您的源代码控制系统中拉出,并使用Debuggable=true进行构建,然后以生成的APK作为起点,而不是使用Play商店中的APK.

One option would be to pull the specific version of the app out of your source control system and build it with Debuggable=true, and use that generated APK as your starting point instead of using the APK from the Play Store.

制作两个版本,而不是只制作一个APK发布版本并将其上传到Play商店.一个版本将照常签名并上传.并使用完全相同的源代码制作另一个具有Debuggable=true的APK.用版本号重命名每个文件.然后,以后,如果您想尝试从任何版本升级到任何版本,都可以这样做,并且仍然具有调试功能.

Instead of making only one APK release version and uploading that to Play Store, make two versions. One version would be signed and uploaded as usual. And with the exact same source code, make another APK that has Debuggable=true. Rename each file with the version number. Then, later, if you ever want to try an upgrade from any version to any version, you can do that, and still have debugging capability.

这篇关于如何在USB连接的设备上的Android Studio中调试应用程序升级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆