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

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 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.
I am really confused. Can anyone explain why I am seeing this message and how I can fix it?

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

Here is my solution:
If you got more than one library version, this may help.
set a breakpoint on the lib source code
let the code run to the breakpoint
you will got these tips
click the arrow icon
you will get this
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

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.

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.

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
Go to Build>Clean Build
Re-RUN the app
Now, the debug runs normal.

These are the steps that worked for me (For both Mac and Windows):
Click on "File"
Click on "Invalidate Caches / Restart ..."
Choose: "Invalidate and Restart"
Note: It will take less than a minute for small projects, but since my project was big (approximately one million lines of code), it took 20 minutes.

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.

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

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!

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

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.

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

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

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.

This happened to me when accidentally I have added the same library multiple times.
implementation 'androidx.appcompat:appcompat:1.1.0'
The above library was added multiple times.

If clean, rebuild, invalidate cache and restart etc. techniques are not working, then try deleting the previous APK and reinstalling the new APK.

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

Related

Source code does not match the bytecode message whiile debugging [duplicate]

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 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.
I am really confused. Can anyone explain why I am seeing this message and how I can fix it?
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
Here is my solution:
If you got more than one library version, this may help.
set a breakpoint on the lib source code
let the code run to the breakpoint
you will got these tips
click the arrow icon
you will get this
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
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.
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.
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
Go to Build>Clean Build
Re-RUN the app
Now, the debug runs normal.
These are the steps that worked for me (For both Mac and Windows):
Click on "File"
Click on "Invalidate Caches / Restart ..."
Choose: "Invalidate and Restart"
Note: It will take less than a minute for small projects, but since my project was big (approximately one million lines of code), it took 20 minutes.
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.
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".
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!
This can also happen in case you have enabled ProGuard. In buildTypes set minifyEnabled false, shrinkResources false, useProguard false
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.
You can created AVD, select API Level equal your tagetApi andr compileApi, it works for me.
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
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.
This happened to me when accidentally I have added the same library multiple times.
implementation 'androidx.appcompat:appcompat:1.1.0'
The above library was added multiple times.
If clean, rebuild, invalidate cache and restart etc. techniques are not working, then try deleting the previous APK and reinstalling the new APK.
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

Android Studio 3.1.3 - Unresolved reference: R - Kotlin

I am new to kotlin, i have converted some code from java but it seems like there's something wrong, The R in findViewById(R.id.my_id) is highlighted in red and it shows this message : "Unresolved reference: R".. I've been looking for a solution but i seem not to figure it out, So what should i do?
Here's a screenshot :
The issue can be caused by many factors,
as mentioned by martomstom in this Answer the issue is sometimes caused by com.android.tools.build:gradle version, changing it's version to a more stable one would solve the problem: for example: com.android.tools.build:gradle:3.4.0-alpha02 with com.android.tools.build:gradle:3.2.1
Also, having libraries from the same group, but with different versions may cause the problem or even more runtime errors. use the exclude group method like the following : implementation('com.squareup.picasso:picasso:2.71828') { exclude(group: 'com.android.support') } in this case, picasso library uses android.support components, the android library version used in picasso is different than the one you're currently using in your app, so in order to solve this issue, we have to exclude it completely from its sub library and class groups.
It can also happen by the mismatch of resources and code, including this importation line in your activity may solve the problem too : import com.package.name.R
Sometimes it can happen because of the IDE, performances or memory.. Cleaning the project from time to time may save you some time, on Android Studio it would be something like this : Build -> Clean Project / Rebuild Project - Cleaning IDE cash also helps with performance and memory, on Android Studio it would look like this : File-> Invalidate Chases/ Restart -> Invalidate Cashes and Restart
I noticed that this problem happens to me the most of the time when importing new resources, Using prohibited characters in their names would fire the error, such as . , , - , UpperCase or special Letters
And as a suggestion , if you're using Kotlin, i really recommend using Kotlin extensions in your activity such as : import kotlinx.android.synthetic.main.activity_page.* or if you're using a custom view : kotlinx.android.synthetic.main.view_layout.view.*
after that, in onCreat() method of an activity , you'll only have to call the id, for example : my_edit_text_ID.text = "Kotlin Dbest!", or from a custom view : mCostumView.my_edit_text_ID.text = "Kotlin Dbest!"
EDIT :
I have faced this issue againe and the problem was the '' R '' library was imported from 2 different sources :
com.android.R
com.example.package.R
You must only import the '' R '' library with your application package name,
in this case com.example.package.R
Sometimes the library is not imported at all, to import it, click on the
unresolved reference R and press Alt + Enter
EDIT:
As tobltobs mentioned in the comments section: " Most of the time the problem is caused by another error which prevents the build system from creating generated sources. To find the root cause look at the gradle log (the "toggle view" icon below of the green hammer in the Build output) and look for errors unrelated to R or BuildConfig (also generated). If there is no other error left and the problem with R persists then maybe something of this list might help. "
EDIT:
As Patrick Beagan mentioned, Kotlin extensions are now deprecated - I'd advise using ViewBinding instead
I used com.android.tools.build:gradle:3.3.0-alpha13 and had the same issue. Changing to stable Version 3.2.1 solved this problem for me.
So this is a misleading error.
The fastest way to get to the root cause is to run:
bash gradlew assembleDebug --debug
then scroll up and look for the real error happening.
However, if it still doesn't seem like you have the answer you are looking for, then read on.
I'm going to explain the 30,000 foot view of what is happening. This is not EXACT order or EXACT flow, it is just pretty damn close ;) so if you know more then I do of the exact order and care to make corrections with links, feel free I won't stop ya :).
The Process
The R file is generated code.
There is an order to the generation.
Gradle will do it's magic, pull it's dependencies and kick off it's
warning and error tree first,
then Android converts all Kotlin to Java behind the scenes. Yup that's
right, our beloved Kotlin still has to be Java to compile for our
beloved ART virtual machine.
Then it runs through and does the adapters that you have created for
JVM Statics and a few other tasks.
Next up it compiles all the xml databinding files first to create the
generated databinding files.
If everything succeeds it moves on to processing the assets and
resources. Which creates pointers or IDs for each resource that you
reference in code. Next it will run through and begin compiling the
code and packaging process after that.
Pretty straight forward process, but here in lies the problem.
The misleading Error
If any step fails before the R generation is complete, then the R does not get generated. Sometimes a simple rebuild is all you need to do, sometimes a simple File->Invalidate Cache and Restart is all you need. However, more often than not you have a code issue in your gradle, your xml, your databinding or your adapters that are preventing the compiler from even reaching the R generation stage.
So the next question is
"Well shoot, how do we troubleshoot it if the errors are worthless or
non-existent".
Well first let's talk about the many ways these errors present themselves.
Duplicate Databinding class found
xml Binding Error at line #
Couldn't find matching signature of bind:customAdapterMethod
Can't find R file of the correct project, only shows import options for sub modules or incorrect namespace R files.
Couldn't find DataBindingUtility or DataBinding for activity/fragment
And many other various ways as well, too many to list them all
Next, let's talk about potential candidates causing the problem. As there are sooo many lol.
Gradle Syncing issues
Bad versions of Gradle or Tools, you may have gone too far forward in your last gradle file modification. Try stepping back one version and "invalidate cache and restart" if that fixed it, great, if not, read on.
Caching Issues (File->Restart and Invalidate Cache)
xml elements with wrong namespace
xml elements with bad IDs or references IDs out of order (i.e. you say align to right of an element that is lower in the xml document then the sibling element that is trying to reference it)
xml data binding issues referencing namespace or member that doesn't exist or is not typed correctly
xml data binding issues in non-auto-filled spots like custom attributes using adapters as those are harder to spot. i.e. bind:myCustomMethod=#"myObject.mistypedProperty()"
JVM Static adapters with issues or duplicated signatures
Duplicated or bad character in the Strings or Dimens file or any other xml file for that matter
Private variable marked for #Binding without properties to access it
Member variable marked for #Binding that matches a parent class method causing duplications that manifests itself in almost impossible errors
Mismatch of types like using an adapter that takes (Int) but you are passing (Int?) via data binding and it isn't recognized with JVM Statics until compile time
You selected IMPORT on a popup to import R file of a sub module instead of the application file
Having bindable members in a child or parent class, but not giving fully qualified namespace to class cast in the XML usage of the parent or child class. As the databinding compiler is not smart enough to realize the variable provided for class Foo is also parentFoo baseclass, so you have to qualify it as android:text="#((com.path.parentFoo)foo).parentMethod"
Having a method name in a class, that matches a "generated property from #Binding member variable" i.e. firstName as a variable, but then having a method called getFirstName in a parent or child class, because you are now matching a method name that will get auto generated, thus causing dataBindingUtility duplication class errors.
There are more causes, but this should give you a series of places to look, but the list can go on and on seriously.
Unfortunately this happens a lot in bleeding edge technologies where the UI tools are not up to speed with the terminal based tools yet. So I suggest you run from the project root in a terminal with
bash gradlew assembleDebug --debug
When it fails, and it will. Start scrolling up through the logs until you find the red where you see what is actually failing and preventing the next stage from occurring.
You will find this especially useful when you start dealing with databinding.
TIP:
When you start dealing with databinding, make sure you compile and run often because the goal is to recognize right away before doing other files to make sure you didn't break generation and make your life MUCH easier to know code you just added caused the issue before getting too far.
Times to compile and run to confirm no issues before moving on.
If you add a few JVM statics compile and run
If you add variables to your XML to use
If you bind to properties of your model in 1 file
If you add a binding to a JVMStatic
If you add bindable members or properties to an model
If you refactor moving observable member variables or properties into children or base classes
Any other xml or binding related elements that can effect the generated code.
Like I mentioned above, the reason is to avoid getting so many changes, that it becomes a troubleshooting nightmare to find a generic vague, horrible error related to generated databinding code. I'm sure the tools will improve, but for now, do yourself a favor and compile and run often when changing Databinding related items.
Happy Coding
Use gradle commands.
In Android Studio, on the right menu:
Gradle -> :app -> Tasks -> build -> clean.
After that, Gradle -> :app -> Tasks -> build -> build
I had wrong import statement import android.R instead of import my.project.package.R. Fixing it solved the problem
I had the same problem, and I tried not to downgrade from gradle version 3.3 to gradle version 3.2.1. Instead I updated Android Studio to version 3.3, which made the trick for me ;-)
This worked for me. How much work it is depends on how big your project is. I started a new project, created the required modules (XML, Kotlin, colors, strings, etc.), then copied the code into the modules in the new project from the modules in the old project. Copying XML saves a lot of time compared to recreating the UI. All in all, it take a little while, but I have spent much more time tring to fix the unresolved reference error without it.
TRY THIS
Go to the content_main.xml file and there you need to change the
android:id="#+id/??????"> line of code to whatever id you have given to your file.
Replace question mark ?????? with the related file id name.(IF you dont know the id go to the design tab on the bottom and click on the related Asset.
On the right side below attributes, you can find the ID you have given to it.
If it is blank you can freshly name it and Android Studio will write the code.
Then restart Android Studio. Hope this will help. Happy coding.
I believe that I came across the real answer (though by accident).
I also, as the OP had my KT file fail to location R. as well as other classes that happen to be in java. What I noticed was that there was a case difference I the filenames. Once I corrected the import statements to match the case of the package (aka, folder) the errors resolved.
I had the same problem with R reference too.
Finally Android Studio 3.3 has been released and using 'com.android.tools.build:gradle:3.3.0' the problem has been fixed!
I update Android Studio to version 3.3.1 and solved this problem.
Downgrading gradle version worked for me.
I changed :
Gradle version from : 4.10.4 to 4.4.1
and Gradle Plugin version from : 3.3.1 to 3.1.3
If your are experiencing this issue in Kotlin because you cannot reference the elements of the xml layout by ids. (e.g. R.id.adView) then try removing the line import android.R from your kotlin file.
For me it was because I had created a new package and R wasn't available until I imported it from the package above
I faced the same issue. I restarted my Android Studio, invalidate caches, Sync Gradle but nothing was working. Then I looked into my file and there are 2 imports of my R. 1 import was related to my application package and the other was related to Android.
import com.example.myApp.R
import android.R // This import was added accidentally during the build.
Removing second import related to android solved this issue.
I had an issue because of this import:
import android.os.Build.VERSION_CODES.*
In the latest version it contains R
I had same problem while using auto-manifest plugin. Adding AndroidManifest.xml explicitly solved the problem to me.
I used to File --> Invalidate Caches... and issue resolved.
Just restarting Android Studio solved it for me.
I also had this problem, Gradle Sync, and Invalidate Cache, and Restarting Android Studio Didn't help. Upgrading and Downgrading Gradle were also not helpful.
What worked for me is: Make Project (Ctrl + F9) and then try to run the project.
I solved this error by following Android Studio's lint tools to upgrade the version of a dependency in the project-level gradle file. In this case, I upgraded androidx.navigation:navigation-safe-args-gradle-plugin from 2.3.2 to 2.5.2 (latest version), then synced the project.
Here is the solution,
File->Project Structure->Project, select Android Gradle Plugin Version as 3.2.1 from the drop-down. then click apply.

Eclipse errors in comment

Using Eclipse I comment out errors as temporary solution.
Every once and a while these errors remain sticky (no way to get the errors away even when code is removed by commenting (comment color confirms the comment)
Save/clean/rebuild/restart of eclipse ... nothing helps any more but a painstaking recreation of the project file by file .... can anyone give me a tip ?
The error text is often removed module can not be resolved, variable can not be resolved
this as only error where the use of the variable is completely removed!
I've the most recent eclipse version but had it with previous versions as well
Thanks in advance, This can save me day's of useless work.
Please try this:
What I usually do is I cut the entire document/file and paste it.
I am using Helios Service Release 1
Ctrl+A, Ctrl+C and then Ctrl+V.
It fixes the problem for me. I hope it does the same for you.
Cheers.
Just go to the problems list where the error/problem is listed and delete the entry, then it should also disappear from the editor.
- Go to the Problems Tab at the bottom of the IDE.
- Remove all the Error and Warning Entries.
- At last Clean the Project.
Try clicking right mouse button and select the option "spelling check". I´ve realised I have this errors when I write comments in my native lenguage, not in english.
I had similar error. The problem in my case was disabled autobuild in Eclipse. (Project > Build Automatically)
click on the comment being where error is shown. Click on "Disable spell check"

Eclipse - debugger doesn't stop at breakpoint

I am trying to trouble shoot a JUnit. In the source code, I have set break point in two places: 1) in a line where a static member is initialized 2) the first line of one of the test cases.
The debugger stops in the static field initializing line. But it doesn't stop in the test case. No matter where I set the break point in the test case, the debugger doesn't stop there. I know for sure that the test case is executed as I can see the log messages that I have added appear in the log.
Any help would be greatly appreciated.
I am using Eclipse Galileo and JUnit4 launcher.
Fix could be as simple as clicking run/skip all breakpoints. Worked for me.
Make sure, under Run > Debug Configurations, that 'Stop in main' is selected, if applicable to your situation.
This could be related to one of the bugs in JDK 6 Update 14, as indicated in the release notes for JDK 6 update 15.
If this indeed turns out to be the issue, you should move to a higher version of the JDK (that's no guarantee though, since fixes have been released against 6u16, 6u18 and 7b1). The best bet is to use -XX:+UseParallelGC flag. Increasing the size of the minimum and maximum heap size, to delay the first GC, bring temporary relief.
By the way, use this bug report in Eclipse to track how others have been faring.
You might have accidentally skipped all break points in Eclipse toolbar. To fix this go to Eclipse -> Run -> Skip All Breakpoints.
Usually when this happens to me (rare but it does) means that the code being executed is different than the code in the editor. It will happen from time to time for Eclipse that the built classes and the code in editor are out of sync. When that happens I get all sort of weird debugger behavior (debugging empty lines, skipping lines of code etc).
Restarting Eclipse, clean all projects and rebuild everything usually clears things up. I had also the Maven plugins (older versions... had not had it for a while now) that had a tendency to do that too.
Otherwise it might be a bug, maybe the one Vineet stated,
Hope this helps
In my case the problem was that I hadn't Debug view open in Debug perspective, so:
1 - Be sure you have debug perspective opened:
2 - Be sure you have debug view opened:
Project -> Clean seemed to work for me on on JRE 8
In order to debugger work with remote, the java .class files must be complied along with debugging information. If "-g:none" option was passed to compiler then the class file will not have necessary information and hence debugger will not be able to match breakpoints on source code with that class in remote. Meanwhile, if jars/class files were obfuscated, then they also will not have any debug info. According to your responses, most probably this is not your case, but this info could be useful for others who face the same issue.
Remove all breakpoints and re-add them.
For JDK7, run->Debug Configurations, check "Keep JUnit running after a test run when debugging".
Happened to me once, when I had unchecked "Run > Build automatically" and forgot to re-check it.
Make sure you declare the package at the top.
In my groovy code this stops at breakpoints:
package Pkg1
import java.awt.event.ItemEvent;
isMule = false
class LineItem {
// Structure defining individual DB rows
public String ACCOUNT_CODE
public String ACCOUNT_DESC
...
This does not stop at breakpoints:
import java.awt.event.ItemEvent;
isMule = false
class LineItem {
// Structure defining individual DB rows
public String ACCOUNT_CODE
public String ACCOUNT_DESC
...
To remove the breakpoints:
Debug your class as a junit test
When your debugger stops, click the "breakpoints" tab next to "variables" and "expressions"
At the top right of the breakpoint tab, click the button with two 'X'
Stop the test, replace your breakpoint and run the debugger again
Also verify if breakpoints on other lines DO work, it may be a bug in the debugger. I have had a problem with the Eclipse debugger where putting a breakpoint on a boolean assignment whose code was on the next line didn't work I reported this here, but putting it on the previous or next line did.
If nothing works-
Remove that Remote/Local Debug Configuration, and Create a new One.
Add the Source in Debug Configurations.
Another possible problem is that the debugger port may be blocked by the firewall. For example, I was using mule anypoint studio (v 5.4.3). The default debugger port is 6666. When a flow is executed, it would not stop at breakpoint. when I changed the port to another (e.g. 8099), it worked fine.
Go to Right click->Debug Configuration and check if too many debug instances are created.
My issue was resolved when i deleted multiple debug instances from configuration and freshly started debugging.
If you are on Eclipse,
Right click on your project folder under "Package Explorer".
Goto Source -> Clean up and choose your project.
This will cleanup any mess and your break-point should work now.
Creating a new workspace worked for me.
In my case I had multiple projects in same workspace. The java file I was trying to debug was present in more than one projects with same package.
I didn't need the other project, so simply closed unrelated projects (or remove the file from unrelated project).
One additional comment regarding Vineet Reynolds answer.
I found out that I had to set -XX:+UseParallelGC in eclipse.ini
I setup the virtual machine (vm) arguments as follows
-vmargs
-Dosgi.requiredJavaVersion=1.7
-Xms512m
-Xmx1024m
-XX:+UseParallelGC
-XX:PermSize=256M
-XX:MaxPermSize=512M
that solved the issue.
It happened to me when I had several project, I realized that I created a spring boot configuration of a project B from a project A (I clicked on Duplicate and change the parameter to have a config for the project B) and in that case I haven't the debug mode so I removed this config and I created directly a new one by clicking New in Spring Boot App
This is what works for me:
I had to put my local server address in the PHP Server configuration like this:
Note: that address, is the one I configure in my Apache .conf file.
Note: the only breakpoint that was working was the 'Break at first line', after that, the breakpoints didn't work.
Note: check your xdebug properties in your php.ini file, and remove any you think is not required.

Eclipse/Java code completion not working

I've downloaded, unzipped and setup Eclipse 3.4.2 with some plugins (noteable, EPIC, Clearcase, QuantumDB, MisterQ).
Now I find when I'm editing Java projects the code completion is not working. If I type String. and press ctrl+space a popup shows "No Default Proposals" and the status bar at the bottom shows "No completions available".
Any ideas?
Try restoring the default options in 'Windows > Preferences > Java > Editor > Content Assist > Advanced'
An example of the kind of data you see in this preference screen, however not necessarily what you currently have.
(From Vadim in this blog post " Content Assist Duplicates in Eclipse (Mylyn)":
if have duplicate Mylyn entries, uncheck the duplicate entries that do not contain "(Mylyn)" in their name)
The Eclipse help page defines the default list to restore:
Select the proposal kinds contained in the 'default' content assist list:
Other Java Proposals,
SWT Template Proposals,
Template Proposals,
Type Proposals
I'm adding an answer here in case someone else finds this on Google. Same symptoms; different problem. For me, the type caches had become corrupt.
From http://mschrag.blogspot.co.nz/2009/01/open-type-cant-find-your-class.html
Quit Eclipse
Go to workspace/.metadata/.plugins/org.eclipse.jdt.core
Remove *.index and savedIndexNames.txt
Restart Eclipse and search Ctrl+T for the offending type. The indexes will be rebuilt.
In case someone comes here and want to activate the autocomplete function, go to
Preferences -> Java -> Editor -> Content Assist.
Then in the Auto Activation section fill in Auto activation triggers for Java:
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._
For those running Xfce + having IBus plugin activated, there might be keyboard shortcut conflict.
See more info on my blog: http://peter-butkovic.blogspot.de/2013/05/keyboard-shortcut-ctrlspace-caught-in.html
UPDATE:
as suggested by #nhahtdh's comment, adding the some more info to answer directly: IBus plugin in Xfce uses by default Ctrl+Space shortcut for keyboard layout switching. To change it, go to: Options and change it to whatever else you prefer.
Check the lib of your project. It may be that you have include two such jar files in which same class is available or say one class in code can be refrenced in two jar files. In such case also eclipse stops assisting code as it is totally confused.
Better way to check this is go to the file where assist is not working and comment all imports there, than add imports one by one and check at each import if code-assist is working or not.You can easily find the class with duplicate refrences.
Another solution which worked for me is to go to Java--> Appearence --> Type Filters and do disable all
None of these worked for me.
I was experiencing this issue in only once particular class. What finally worked for me was to delete the offending class and recreate it. Problem solved... mystery not so much!
If you have installed Google Toolbar for IE, may be you can face the same problem. Because, the toolbar capture the shortcut ctrl+Space.
I had this problem and like #Marc, only on a particular class. I discovered that I needed to designate Open With = Java Editor. As a Eclipse newbie I hadn't even realized that I was just using a plain text editor.
In the package explorer, right-click the file and chose "Open With".
I faced this problem, and spent hours trying to figure out the issue. tried to follow the steps mentioned in the different answers above, the solution I found is on the same lines as Mona suggested, but slightly different. Tried to add as a comment to Mona's answer but no option was available.
Issue with my eclipse was, classpath somehow got corrupted and all the jars and dependent projects were missing. after taking the latest .classpath from repository it worked fine.
Check that you did not filter out many options inside the Window > Preferences > Java > Appearance > Type Filters
Items in this list will not be appear in quick fix, be autocompleted, or appear in other various places like the Open Type dialog.
I also face this issue but it is resolved in different way.
Steps that I follow may be helpful for others.
Right click on project (the one you are working on)
Go to Properties > Java Build Path > JRE System Library
Click Edit... on the right
Choose the JRE 7
Once you have you configuration checked and completion is still not working:
make sure you have the right directory structure.
Do you see the right icon beside the file?:
It will tell you how the file will be treated by Eclipse:
I am posting this answer as I had that story with with Maven webapp artifact. By default Maven-WebApp does not create folder for sources and I put my Java into resources, wondering for 5 minutes what was going on... :)
Running STS on Java Spring Boot projects, here's what works for me :
Maybe this helps other people who come across the same issue.
My setup: old Gradle project (version Gradle 2.12) made by someone else, imported using the Gradle Import Wizard into STS (Eclipse Oxygen.2 (4.7.2)).
Code completion did not work either (and I still have hollow Js at the Java files), but at least I got the code completion to work by doing:
right click on the project folder > Properties > Gradle > Configure Workspace Settings > Java > Editor > Content Assist > Advanced
check "Java Proposals in upper window.
2x Apply & Close
I have run into this problem since upgrading to Eclipse 2019-09. Based on some of the suggestions above, this is what worked for me.
I had to go to Eclipse -> Preferences -> Java -> Editor -> Content Assist -> Advanced.
I found out that if I turn on any of the key binding proposals, Java Non-Type, Java, Java (Task-Focused) or Java Type proposal, then I was able to use auto complete. If I turned them all on, then not only did auto complete work, but I got duplicate methods listed. I am guessing, but I will probably used Java Type Proposals. Any clarification of what differs for these four types would be appreciated.
In my case, Intellisense had only disappeared in a few classes in one project. It turned out this was because of a missing library on the build path (although it worked previously).
So definitely check all the errors or problems in Eclipse and try to find if a library may be missing
For those who use the latest 3-19 eclipse build:
It just happened to me when upgrading from Oxygen to 3-19 eclipse version, so I assume the auto-complete feature does not migrated correctly during the upgrade process.
The only solution that worked for me was to create a new eclipse workspace, and import the project/s to it. It might take a few minutes, but it worth it - comparing to the time spent on other solutions...
I ran into this and it ended up being I was opening the file with the text editor and not the java editor.
For me the issue was a conflict between several versions of the same library. The Eclipse assist was using an older version than maven.
I had to go to the .m2 directory and delete the unwanted lib version + restart eclipse.
I experience problems on Eclipse Neon when editing a file which does not belong to the project directory. When I copy the same file to the project root directory, not even to the src directory, the completion starts working.
When the file is opened from a different directory, only completion for JRE works. That is for example: java. completes, but junit. does not.
Just in case anyone got to a desperate point where nothing works... It happened to us that the content assist somehow shrunk so no suggestion was shown, just the "Press Ctrl+Space for non-Java..." could be seen.
So, it was just a matter of dragging the corner of the content assist to enlarge the pop-up.
I know, embarrassing. Hope it helps.
Note: this was an Ubuntu server with Xfce4 using Eclipse Oxygen.
If you're experiencing this in an enum, or when initializing an array with anonymous classes, it's a known bug in Eclipse. See Eclipse content assist not working in enum constant parameter list.
We can change the settings as per our requirement.
Suppose we want to make java proposal as highest priority we need to do changes as shown below.
Windows > Preferences > Java > Editor > Content Assist > Advanced
Choose Java proposal and click on up button
For me in Sep 2021 it was an odd Eclipse bug. I had a multi-line string inside an annotation in my Class. This caused just that particular class to fail when trying to code complete (even though the class compiled just fine).

Categories