简体   繁体   English

如何为特定设备测试我的应用?

[英]How can I test my app for a specific device?

I am building an application with React Native but the app not working well on a few android devices. 我正在使用React Native构建应用程序,但该应用程序在一些Android设备上无法正常运行。 So I need to see what's going wrong but I don't know how to set up an emulator for a specific device. 因此,我需要查看出了什么问题,但我不知道如何为特定设备设置仿真器。 Are these problems depends on phone's brand and model or it just depends on their android versions? 这些问题是取决于手机的品牌和型号还是仅取决于其Android版本?

Its not really possible. 这不是真的可能。 There's two major problems: 有两个主要问题:

  1. Software. 软件。 Real devices don't ship pure AOSP like runs on the emulator. 真实设备不会像在模拟器上运行那样提供纯AOSP。 They add patches and features and there's no way to know what they actually run. 他们添加了补丁和功能,无法知道它们实际在运行什么。
  2. Custom UIs. 自定义用户界面。 Many phones provide custom UIs like TouchWhiz and the like which can override Android behavior 许多手机都提供自定义UI(例如TouchWhiz等),可以覆盖Android行为
  3. Hardware. 硬件。 If your app depends on things that are very hardware specific, like GPS or Camera, they could have issues due to hardware bugs. 如果您的应用依赖于非常特定于硬件的事物(例如GPS或相机),则可能由于硬件错误而出现问题。

If you just want to emulate a specific OS version like KitKat, or specific low memory conditions its possible via emulator configuration. 如果您只想仿真特定的OS版本(例如KitKat)或特定的低内存条件,则可以通过仿真器配置来实现。 If you really need to test on a device, either buy one or use a service that allows you remote control over specific devices. 如果您确实需要在设备上进行测试,请购买一个设备或使用一项服务,该服务可让您远程控制特定设备。 Amazon has a nice device farm that you can rent over AWS. 亚马逊有一个不错的设备场,您可以通过AWS租用它。

One of the biggest challenges when developing for Android is the wide variety of devices and "optimizations" manufacturers make to their Android versions. 为Android开发时,最大的挑战之一是制造商对其Android版本进行的各种设备和“优化”。

The Android emulator is based on AOSP (vanilla Android) and was only recently published with Google services included. Android模拟器基于AOSP(香草Android),并且直到最近才发布,其中包含Google服务。 This is the most clean version of Android. 这是最干净的Android版本。 You can use the emulator to test UI scaling for different screen sizes but it will always behave like an AOSP Android. 您可以使用模拟器来测试针对不同屏幕尺寸的UI缩放,但它的行为始终类似于AOSP Android。 Google packs a bunch of hardware configurations into Android Studio which you can simply select when creating an virtual device. Google将许多硬件配置打包到Android Studio中,您可以在创建虚拟设备时选择它们。 You can always create a custom hardware profile with custom screen size and resolution. 您始终可以创建具有自定义屏幕尺寸和分辨率的自定义硬件配置文件。 Some manufacturers also change the DPI value of the OS causing the UI to be bigger or smaller, keep this in mind when creating a custom hardware configuration. 一些制造商还会更改OS的DPI值,导致UI变大或变小,在创建自定义硬件配置时请记住这一点。

Further, you can use the emulator to test the default behaviour on different Android versions. 此外,您可以使用模拟器在不同的Android版本上测试默认行为。 Again, manufacturers change their Android usually causing slightly different behaviour. 同样,制造商更改其Android通常会导致行为略有不同。

I assume that your question is focussed on different behaviour of eg Samsung phones having crashes only occuring in Samsung phones (Samsung can be exchanged with any other brand here). 我认为您的问题集中在不同的行为上,例如三星手机仅在三星手机中发生了崩溃(三星可以在这里与任何其他品牌交换)。 Unfortunately, there is no simple way to test this but getting your hands on the faulty device. 不幸的是,没有简单的方法来测试此问题,而是让您接触故障的设备。 One option is to use a cloud based test lab (eg Firebase Test Lab, App Center or AWS device farm) to test your code on the faulty device or rent the device at a local shop. 一种选择是使用基于云的测试实验室(例如Firebase测试实验室,App Center或AWS设备场)在有故障的设备上测试您的代码或在本地商店租用该设备。 Most bigger cities have companies renting phones and tablets on a daily or weekly basis. 大多数较大的城市都有公司每天或每周出租电话和平板电脑。

In the end you will need if statements checking for a specific device, manufacturer or Android version or any combination of them and doing something slightly different to fix the undesired behaviour. 最后,您将需要if语句检查特定的设备,制造商或Android版本或它们的任意组合,并做一些稍有不同的操作来修复不良行为。

I know that this is not the answer you are looking for, but it's the best I can offer. 我知道这不是您要寻找的答案,但这是我能提供的最好的答案。 To tell a little tale of my worst experience: I had once a bug were calling a crypto function caused a kernel panic on HTC (?) phones. 告诉我一个我最糟糕的经历的故事:我曾经有一个错误,即调用加密函数导致HTC(?)手机出现内核恐慌。 This means the user opened my app and the phone rebooted. 这意味着用户打开了我的应用程序,然后电话重新启动。 I was required to implement the entire encryption logic again just for HTC with Android 6.0. 我被要求仅针对具有Android 6.0的HTC再次实现整个加密逻辑。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM