“源代码与字节码不匹配".华为的系统文件 [英] "Source code does not match the bytecode" for system files on Huawei

查看:571
本文介绍了“源代码与字节码不匹配".华为的系统文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在调试其中一个应用程序的问题,该问题仅影响华为设备.为了对其进行调试,我们购买了P20 Lite ANE-LX1.我们在代码中放置了一些断点,并正在研究完整的堆栈跟踪.该设备已安装Android 8.0,并且我们在Android Studio中下载了相同的SDK.

We are debugging an issue with one of our apps which affects only Huawei devices. To debug it, we purchased P20 Lite ANE-LX1. We've placed some breakpoints in our code and are investigating the full stack trace. The device has Android 8.0 installed, and we have the same SDK downloaded in our Android Studio.

当我们将设备连接到调试器并尝试调查堆栈跟踪时,我们在系统源文件中得到以下错误:

When we attach our device to a debugger and try to investigate the stack trace we get the following errors in system source files:

在使用堆栈跟踪之后,我们可以确认我们的源文件确实与设备上安装的文件不对应.有时,调试器指向调用functionA的行,在堆栈跟踪中,我们看到改为调用了functionB.我们可以确认的文件受此问题影响:

After playing with the stack trace, we can confirm that indeed our source files do not correspond to what is installed on the device. Sometimes, the debugger points to a line where functionA is called, and in the stack trace, we see that functionB is called instead. The files which we could confirm are affected by this issue are:

  1. VideoView
  2. MediaPlayer
  3. ContentProvider.
  1. VideoView,
  2. MediaPlayer,
  3. ContentProvider.

我们已经尝试了所有可能的解决方案,包括清理项目,从Android Studio删除任何其他SDK,修改项目设置-都无助于解决此问题.

We've tried all the possible solutions which we could find, including cleaning the project, deleting any additional SDKs from Android Studio, modifying project settings - nothing helps to resolve this issue.

这使我们相信,华为在其设备上安装了Android 8.0的修改版,这就是为什么我们无法调试系统文件的堆栈跟踪的原因.我们确实联系过华为,试图对此进行澄清.

This leads us to believe that Huawei installs a modified version of Android 8.0 on their devices which is why we cannot debug the stack trace for the system files. We did contact Huawei to try and clarify this.

同时,如果您能向我们提出任何相关的想法,我们将不胜感激.也许您知道从何处获取华为在其设备上安装的源文件?或者,也许您知道如何以其他方式解决源代码和字节码之间的这种不匹配?

In the meantime, we'd appreciate if you could throw any relevant ideas at us. Maybe you know where to get the source files which Huawei installs on their devices? Or maybe you know how to fix this mismatch between source code and bytecode in some other way?

按照罗伯特的建议,我卸载了Android 26的源代码,然后在我的华为上再次运行了该应用程序.跳转到VideoView文件后,我看到了以下图片:

Following the advice of Robert, I uninstalled the source codes for Android 26 and ran the app again on my Huawei. As soon as I jumped into the VideoView file, I saw the following picture:

我点击下载",它开始下载源文件:

I clicked on "Download" and it started downloading the source files:

此后,我能够进入VideoView,它似乎工作正常.但是,在这一行之后,很明显这些源文件也是错误的:

After this, I was able to step into VideoView and it seemed to work fine. However, after this line it became obvious that these source files are also wrong:

当我尝试进入requestLayout函数时,我得到了:

When I try to step into the requestLayout function I get this:

这显然是错误的结果.实际上,如果我单击转到下一行",则会再次看到有关源代码与字节码不匹配的消息.

And it is obviously a wrong result. In fact, if I click on "Step to the next line" I see the message about source code mismatch with the bytecode again.

推荐答案

显然,华为派生了AOSP并对其进行了修改.这是许多制造商所做的事情,并且只要源代码通过兼容性测试套件就可以了.我本人在华为P20上看到了加密的视频播放问题,这与他们自定义ROM的方法有关.

Apparently Huawei forked AOSP and modified it's sources. This is what many manufacturers do and it's perfectly fine as long as source passes the Compatibility Test Suite. I myself saw encrypted video playback issues on Huawei P20 related to their approach to customizing the ROM.

但要点到了-您可以从/system/framework/arm/boot.oat或boot-framework.oat或/system/framework/boot.vdex获得在设备上运行的确切框架代码.我不完全知道这些文件的结构,但是在Android版本和制造商之间会有所不同.通过adb pull获得这些文件后(您肯定需要root才能执行此操作),您可以使用dex2jar或其他工具执行oat-> dex,dex->​​ jar,并获得源代码.传统上可以从/system/framework/framework.jar获取框架代码,但是在引入ART之后,这些文件通常在系统映像上为空,而是使用预编译的框架代码.

But getting back to the point - you can get the exact framework code running on your device from /system/framework/arm/boot.oat or boot-framework.oat or /system/framework/boot.vdex. I don't know exactly how these files are structured but it varies between Android versions and between manufacturers. Once you get these files by adb pull (You surely need root to do this) you can perform oat->dex, dex->jar using dex2jar or other tools and you'll get the source. Traditionally it was possible to get framework code from /system/framework/framework.jar but after ART was introduced these files are often empty on system images and precompiled framework code is used instead.

这篇关于“源代码与字节码不匹配".华为的系统文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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