'Source code does not match the bytecode'

2020-01-28 04:15发布

I have an app which I am compiling against API level 21: enter image description here

and then debug it on a real device with API level 23:

enter image description here

The problem is when I try debugging through the Android OS's own classes, I get 'Source code does not match the bytecode'. Why is this happening? The test device the app is running on is API level 23, and the source file being debugged is level 23 as well. *enter image description here*

I am really confused. Can anyone explain why I am seeing this message and how I can fix it?

12条回答
Melony?
2楼-- · 2020-01-28 04:26

There's an open issue for this in AOSP, where some users have given possible solutions: https://code.google.com/p/android/issues/detail?id=225199&sort=-id&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars

The potential solutions given there (as of the date of this post) are:

  • Click Build->Clean
  • Disable Instant Run, in Settings->Build, Execution, Deployment
查看更多
你好瞎i
3楼-- · 2020-01-28 04:28

Go to Project Settings > Artifacts. Select the artifact which has the problem. There is an option "Include in project build". This needs to be checked(enabled). For older versions of IntelliJ this option is "Make on build".

查看更多
不美不萌又怎样
4楼-- · 2020-01-28 04:31

This can also happen in case you have enabled ProGuard. In buildTypes set minifyEnabled false, shrinkResources false, useProguard false

查看更多
我命由我不由天
5楼-- · 2020-01-28 04:32

here is my solution

if you got more than one version libraries, it may help.

  1. set a breakpoint on the lib source code
  2. let the code run to the breakpoint
  3. you will got these tips

    enter image description here

  4. click the arrow icon

  5. you will got this

    enter image description here

  6. double click to select the correct lib (normally the highest version of the lib is correct)

    if have clicked the "disable" button by mistake, you can enable it in the debugger setting

enter image description here

if you do not have the tips in the step 3, maybe you can check whether you have checked the setting options.

查看更多
兄弟一词,经得起流年.
6楼-- · 2020-01-28 04:33

I tried all the solution given here and none of them worked for me. In version 2019.1.3 I just clean & rebuild artifact and it worked; first do Build -> Build Artifacts... -> <select your artifact> -> Clean then click Build or Rebuild from same place.

查看更多
我想做一个坏孩纸
7楼-- · 2020-01-28 04:34

Android Studio takes source version equal to Target Version in your application. Compilation performed with source version equal to above mentioned Compile Version. So, take care that in your project Compile Version == Target Version (adjust module's build.gradle file).

查看更多
登录 后发表回答