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

前端 未结 15 1697
时光取名叫无心
时光取名叫无心 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:13

    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).

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

    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.

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

    You can created AVD, select API Level equal your tagetApi andr compileApi, it works for me.

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

    You should use an Android emulator with the same api level as the compileSdkVersion. In your case you should use Android emulator with api level 21.

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

    Here is my solution:

    If you got more than one library version, this 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

    1. click the arrow icon

    2. you will get this

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

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

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

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

    My app is compiled on API LEVEL 29, but debugging on real device on API LEVEL 28.I got the warning source code does not match the bytecode in AndroidStudio.I fixed it thought these steps:

    1. Go to Preferences>Instant Run: uncheck the instant run

    2. Go to Build>Clean Build

    3. Re-RUN the app

    Now, the debug runs normal.

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