'Source code does not match the bytecode' when debugging on a device

前端 未结 15 1699
时光取名叫无心
时光取名叫无心 2020-11-28 08:07

I have an app which I am compiling against API level 21:

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

The problem is when I try debugging

相关标签:
15条回答
  • 2020-11-28 08:23

    There's an open issue for this in Google's IssueTracker.

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

    • Click Build -> Clean
    • Disable Instant Run, in Settings -> Build, Execution, Deployment
    0 讨论(0)
  • 2020-11-28 08:24

    Probably this error message can have more than one cause, my case was not like the one from the OP, in my case this was due to a 3rd party library that required additional libraries.

    For example: you manually add X.jar to your LIB, but this X.jar requires Z.jar to work.

    It took me sometime to figure out, the message was not helping at all. I had to debug the app until I reached the crashing class, and in that class make sure that all imports were satisfied.

    (Particualry: I added MercadoLibre-0.3.4.jar, which required commons-httpclient.jar)

    Hope this helps!

    0 讨论(0)
  • 2020-11-28 08:26

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

    0 讨论(0)
  • 2020-11-28 08:27

    If you use Gradle, it is probably a problem with Gradle caches. (Reference). Alas, even if you run

    gradle --refresh-dependencies
    

    , it is not refreshing really all dependencies. Some rubbish remains. (Reference).

    So, the most sure (but drastic and long) variant is to clear all inside from the [user]/.gradle/caches. Or to find your problem project there and clear only its caches.

    0 讨论(0)
  • 2020-11-28 08:31

    This is the steps that worked for me (For both Mac and Windows):

    1. Click on "File"
    2. Click on "Invalidate Caches / Restart ..."
    3. Choose: "Invalidate and Restart"
    4. Wait for 20 minutes
    0 讨论(0)
  • 2020-11-28 08:35

    So I created an account just so I could help fix this problem that is plaguing a lot of people and where the fixes above aren't working.

    If you get this error and nothing here helps. Try clicking the "Resume program play button" until the program finishes past the error. Then click in the console tab next to debug and read the red text.

    I was getting that source code error even though my issue was trying to insert a value into a null Array. Step 1 Click the resume button

    Step 2 Click the console tab and read the red text

    0 讨论(0)
提交回复
热议问题