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".
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.
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)
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).
I had the same issue and found a solution. If you have a line flagged in red, it will give you this error, but if you un-flag all of the lines it will work normally.
by flagged I mean when you click on the left side where the line numbers are and it highlights the line.
If that is not clear here are pictures.
go from:
flagged line
to:
not flagged line
I tried the solutions given here while working on an application that used Bluetooth Low Energy(BLE). I tried,
Clean Build
Disabled Instant Run
Invalidate Caches / Restart
all of these failed.
What I did was debug the points where I thought I was getting the warning, I still got the warning but the application was working fine. You can disregard the warning.
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.
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:
Go to Preferences>Instant Run: uncheck the instant run
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
here is cause of why I got this error "source code does not match bytecode". My cause doesn't have anything to do with any API, compiler version..... It is caused by when inflate a layout view into a root view while I mistakenly initiate the inflator in else where (a chuck of "result handler" code that put on top of onCreate function of android app code). Somehow the debugger doesn't give me right hint of this (ex, inflator is not initialized or has instance) when breakpoint is set and stop here.