博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
要记住的Facepalm:我在未先测试SDK的情况下对其进行了改进。
阅读量:2519 次
发布时间:2019-05-11

本文共 5465 字,大约阅读时间需要 18 分钟。

by Rahul Chowdhury

通过拉胡尔·乔杜里

要记住的Facepalm:我在未先测试SDK的情况下对其进行了改进。 (A Facepalm to Remember: I bumped up the version of an SDK without testing it first.)

It all started when Google made its App Shortcuts API available for developers on Android. I was super excited to add this to my hash tagging Android app, . So I started digging through for steps to implement it.

一切始于Google向Android开发人员提供其App Shortcuts API时。 我很高兴将其添加到我的哈希标记Android应用 。 因此,我开始仔细阅读 ,以了解实施该的步骤。

The first thing I noticed was the required API version for Android targetSdkVersion was higher than what I was using. “No big deal,” I thought. And I bumped it up to a newer version.

我注意到的第一件事是Android targetSdkVersion所需的API版本高于我所使用的API版本。 “没什么大不了的,”我想。 我将其升级到了新版本。

错误” (The “Mistake”)

Bumping up my SDK version wasn’t a mistake. The mistake was that I didn’t test the app extensively on the latest version of Android. I just added the shortcut feature, tested that out thoroughly, then pushed my changes — without realizing that a major API change had been made to this new version of the SDK.

提高我的SDK版本并不是一个错误。 错误是我没有在最新版本的Android上进行广泛的测试。 我只是添加了快捷方式功能,对其进行了全面测试,然后推送了更改-但没有意识到对这个新版本的SDK进行了重大的API更改。

Android Nougat enforces a check on the scope of files shared across apps in the system. If you try to share a file that is saved within the scope of your app with some external app using the traditional file:// approach, your app will hit a FileUriExposedException, causing your app to bring up that ugly crash dialog that no developer — and certainly no user — wants to ever see.

Android Nougat会强制检查系统中各个应用之间共享的文件范围。 如果您尝试使用传统的file://方法与某些外部应用程序共享保存在应用程序范围内的file:// ,则您的应用程序将遇到FileUriExposedException ,从而导致您的应用程序显示出一个丑陋的崩溃对话框,没有开发人员可以打开该对话框肯定没有用户-想要见识。

How I fixed this exception is beyond the scope of this article. Instead let me share how this one silly mistake affected my app.

我如何解决此异常超出了本文的范围。 相反,让我分享这个愚蠢的错误如何影响我的应用程序。

问题” (The “Problem”)

Before, when I targeted Android Marshmallow users, my app always managed to sneak out through that hidden door known as “compatibility mode” when running on Nougat. So I was totally chilled out knowing that my app ran fine on the latest version of the OS.

以前,当我以Android Marshmallow用户为目标时,我的应用程序在Nougat上运行时,总是设法通过被称为“兼容模式”的隐藏门偷偷溜走。 因此,当我知道我的应用程序在最新版本的操作系统上运行良好时,我感到非常激动。

android {     defaultConfig {         minSdkVersion 18         targetSdkVersion 23 //Targeting Marshmallow    }}

But now things were slightly different for my poor little app. Since it said that it was targeting the latest version of Android, the OS assumed that it had been tested well for all new API updates, and should be punished for any violations. In my case, this was FileUriExposedException, as I was sharing photos using the traditional file:// approach instead of upgrading to a safe and robust solution.

但是现在对于我可怜的小应用程序来说,情况有所不同。 由于它说的是针对最新版本的Android的操作系统,因此该操作系统假定它已经针对所有新的API更新进行了良好的测试,并应就任何违规行为受到惩罚。 就我而言,这是FileUriExposedException ,因为我使用传统的file://方法共享照片,而不是升级到安全可靠的解决方案。

android {     defaultConfig {         minSdkVersion 18         targetSdkVersion 25 //Targeting Nougat 7.1    }}

The ultimate penalty? “Unfortunately, Magnify has stopped working.

终极惩罚? “很遗憾,Magnify已停止工作。

“更大的问题” (The “Bigger Problem”)

Though the crash was a serious problem itself, I had yet to discover an even bigger problem. Since Android Nougat was only available to around 0.6% Android phone users at that time — and to around 2–3% of people using my app — this was a crash that could have been hidden for weeks.

尽管坠机本身是一个严重的问题,但我还没有发现更大的问题。 由于当时只有约0.6%的Android手机用户以及大约2-3%的使用我的应用的用户可以使用Android Nougat,因此该崩溃本可以隐藏数周。

Fortunately, one of my app users had a Google Pixel running Nougat, and it was she who brought to my attention that the app was broken. I patched it up and rolled out another update with the fix to this crash, which thankfully most users were unaware of, as I was notified of the issue within a day or two.

幸运的是,我的一个应用程序用户有一个运行Nougat的Google Pixel,正是她引起了我的注意,该应用程序已损坏。 我对其进行了修补,并针对此崩溃修复了问题并发布了另一个更新,但值得庆幸的是,由于一两天内收到有关此问题的通知,大多数用户没有意识到这一点。

Phew! That was really really close.

! 那真的非常接近。

我该如何解决? (How did I solve it?)

Yeah yeah, I said that I won’t be getting deep into solving the problem, but it’s kind of hard for me to watch a fellow developer struggle on the same problem I had, knowing that I could have helped and added some happy moments to their life.

是的,我说我不会深入解决问题,但是我很难看着开发人员在我遇到的同样问题上苦苦挣扎,因为知道我本可以提供帮助并给他们增加一些快乐的时光他们的生活。

Here’s how I did it:

这是我的做法:

故事的道德启示 (Moral of the story)

Never ever — and I repeat never ever — roll out an update to your software without very, very extensive testing when you have bumped up the version of your SDK. Chances are there are some API changes you were unaware of — some of which might break your software for good.

当您提高SDK版本的功能时,再也不会,而且我也永远不会重复-对软件进行更新,而无需进行非常非常广泛的测试。 您可能没有意识到某些API更改,其中一些可能永久破坏了您的软件。

Make sure you ship your updates only after proper testing. A little time spent testing can save a lot of time getting back the trust of your users.

确保仅在经过适当测试后才发布更新。 花一点时间进行测试可以节省大量时间来恢复用户的信任。

Oh, and:

哦,还有:

There are no mistakes, save one: the failure to learn from a mistake. — Robert Fripp
除了一个错误,没有错误:没有从错误中学习。 —罗伯特·弗里普

Because you don’t end a dope article without a kickass quote. ? ✌️

因为您不会在没有kickass引号的情况下结束浓汤文章。 ? ✌️

If you enjoyed this story, please do recommend it to other people by hitting the ? button on this page, and follow me for more stories about programming.

如果您喜欢这个故事,请通过点击来将其推荐给其他人。 按钮,然后关注我以了解有关编程的更多故事。

翻译自:

转载地址:http://vtgwd.baihongyu.com/

你可能感兴趣的文章
Python——交互式图形编程
查看>>
经典排序——希尔排序
查看>>
团队编程项目作业2-团队编程项目代码设计规范
查看>>
英特尔公司将停止910GL、915GL和915PL芯片组的生产
查看>>
Maven配置
查看>>
HttpServletRequest /HttpServletResponse
查看>>
SAM4E单片机之旅——24、使用DSP库求向量数量积
查看>>
从远程库克隆库
查看>>
codeforces Unusual Product
查看>>
hdu4348 - To the moon 可持久化线段树 区间修改 离线处理
查看>>
正则表达式的搜索和替换
查看>>
个人项目:WC
查看>>
地鼠的困境SSL1333 最大匹配
查看>>
flume+elasticsearch+kibana遇到的坑
查看>>
【MM系列】在SAP里查看数据的方法
查看>>
C#——winform
查看>>
CSS3 transform制作的漂亮的滚动式导航
查看>>
《小强升职记——时间管理故事书》读书笔记
查看>>
Alpha 冲刺(3/10)
查看>>
Kaldi中的Chain模型
查看>>