Android ORMLite DatabaseConfigUtil - java

I'm using ORMLite on our Android app, and I've previously set up an ormlite_config.txt as described in the documentation
http://ormlite.com/docs/table-config
I've now updated my classes, so I need to regenerate the file, but I can no longer get my DatabaseConfigUtil to run in Eclipse. I've set the Run Configuration as described in the documentation, choosing the local JRE and removing the Android bootstrap entry from the Classpath tab. But I just get a whole bunch of java.lang.NoClassDefFoundError for all the Android-derived classes in my project.
I've obviously changed something since I originally generated the ormlite_config.txt file, as I didn't have any problems before, but I can't see what I've done to break everything.
Can somebody tell me exactly what I should have in my Classpath / source tabs?

In the end the instructions in the documentation were all that was required, there was just a pair of bugs introduced in 4.43 that prevented it working as it should. These have now been fixed, and will presumably be in the next version. See https://groups.google.com/forum/?fromgroups=#!topic/ormlite-android/nBuQTVpCs0g

I ran into this exact problem and found out a solution myself.
I think the problem came from Google's ADT plugin. Since the plugin manages the Android libraries as private libraries, ORMLite Util cannot find the Android related classes in the project's build path.
The solution is to manually add the android.jar from your android sdk folder (in my case it's C:\android-sdk\platforms\android-18) into the build path as an external jar.
Hope it helps.

You have to remove the Android Lib from Bootrap Entries!
Do as follows:
Project > Properties > Run/Debug Settings
Select the class you want to compile and click edit
open tab "classpath" and remove Android Lib from Bootstrap Entries

Related

Multiple dex files define Lokhttp3/ResponseBody$BomAwareReader [duplicate]

I know this question has been asked here a few times before. But i haven't seen any possible solution yet.
Before i make the project 'Run as Android Application' , if i do not clean it, i receive the following error and have to restart Eclipse ... and clean again.
Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define
Lcom/jstun/core/attribute/MessageAttributeInterface;
com.jstun.core... is a part of my src folder, of course i can't remove it. And even if i remove that package, another package will show up as an error like:
Unable to execute dex: Multiple dex files define
Landroid/support/v4/app/ActivityCompatHoneycomb;
I've seen this error since updating to ADT 15, i'm using Eclipse Galileo on Ubuntu
Do you have any idea? Thanks for any reply!
This is a build path issue.
Make sure your bin folder is not included in your build path.
Right click on your project -> go to properties -> Build Path.
Make sure that Honeycomb library is in your libs/ folder and not in your source folder.
Include the libraries in libs/ individually in the build path.
BTW, you may want to bring in the android-support-v4 library to get Ice Cream Sandwich support instead of the Honeycomb support library.
I have encountered a similar error today and the reason was that the support library was referenced by two library projects used by my app project but with different versions.
In more details:
My app depends on 2 library projects
FaceBookSDK 3.0 -> which is referencing android-support-v4
ActionBarSherlock -> which is referencing android-support-v4 but with a modified version to support maps.
To solve the problem I had to make FaceBookSDK library depend on ABS library instead of the support library directly.
Well for me, I deleted the file in the libs folder called android support v4.jar and it all worked out. Goodluck :)
I had the same error happening and every time I fixed it, it would come back after I restarted Eclipse.
First of all, as other people said, make sure you do not have multiple copies of the same .jar file around your projects.
In my case, I had a main project that used ActionBarSherlock (among other library projects). The trick that worked for me was going into ActionBarSherlock --> Properties --> Java Build path --> Order of Export and unselecting Android Private Libraries. Then going into Project -> Clean and now you should be able to build the project correctly.
Now, for some reason, every time I restart Eclipse, it automatically enables that checkbox, so I have to repeat this process again.
Hope this helps some lost soul out there :)
Go to Project/properties and Java Built Path and unchecked the Android Private Libraries
To me, just go to Project Properties >> Java Build Path >> Order and Export. Uncheck all external library, as the image bellow. It work for me. Hope this help.
I have also faced this problem in my project. AVD is not able to reload assets,lib,res and etc folder contexts.
problem :
Dex Loader] Unable to execute dex: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl.
Then,I created new projects and copied MainActivity.java,activity_main.xml, drawable context.
Then delete old project from package explore,restart your Eclipse and AVD.
My project is now working properly.... :)
I hope this steps will help u little bit folks..!!
I have same issue, what i tried is:
List item
Open Project Build Path,
Select "Libraries" tab,
Remove all library except the Android Library
Adding all required JARs Files,
And Done!
It works for me, thanks.
If some of you facing this problem with facebook-connent-plugin for phonegap
try to remove files in bin/class/com/facebook/android directory ! -> and rebuild
As others mentioned, this occurs when you have multiple copies of the same class in your build path, or elsewhere in your setup.
I had added android-support-v4.jar to my libs/ folder, and somehow eclipse added a second copy to bin/classes/android-support-v4.jar.
You can test for this with
grep -r YourOffendingClassName YourApp | grep jar
Deleting the extra copy in bin/classes solved the problem - unsure why Eclipse made a copy there.
I got this error for another reason. I was mistaking adding both the v4 AND the v13 support library. This was not necessary for me since my minSdkVersion is 15.
I fixed it by only including the v13 support library. Also, make sure to check mark the library in your exported library build path in eclipse. I also moved it to the top.
Even after going through multiple answers, no solution worked for me.
I deleted "Android Dependencies" from the build path.
Added all the jar files again to the build path and the error was gone.
Somehow eclipse seemed to cache the things.
I'm leaving this answer for someone who gets in this scenario as I did.
I stumbled here and there before noticing that I mistakenly dragged and dropped the Support Library JAR file into my src folder and it was lying there. Since I had no idea how it happened or when I dropped it there, I could never imagine something was wrong there.
I was getting the same error, I found the problem after sometime and removed it. Project is now working fine.
The Solution for me was just to do following things:
->lib directory in your project and delete any multiple elements.
Project->Properties->Java build Path and delete any Dependency Library was added automatically and not by you! ->Apply
Restart Eclipse IDE
Now Clean the project.
Run/Debug on Device/Emulator the project ...
Good Luck
My problem at first was:
Unable to execute dex: java.nio.BufferOverflowException. Check the Eclipse log for stack trace.
1) I Right click on my project -> Android Tools -> Add Support Library
(Run my app...Didn't work so I keep it going...)
2) Right click on my project again -> Properties -> Android -> Check Android 4.1.2 (16) on Project Build Target
(Run the app again...and get this:
Unable to execute dex: Multiple dex files define Landroid/support/v4/app/BackStackState;
3) So I went to the "lib" folder on my project and delete the "old" Android.support.library.jar
(Run the app and cross fingers and...)
¡IT WORKS!
Hope it helps someone...Thanks people!
I have had this issue and that doesn't mean, that the same library is loaded many times but System is trying to load a class with the same name and possibly same package name simultaneously, i.e.
com.pack1.de and Class Geometry of library1.jar
and another
com.pack1.de and Class Geometry of library2.jar.
How should you approach?
You should analyze which methods are being used, a method of library1.jar or library2.
There are 2 Solutions,
Rename a packagename and then dalvik interprets, that they are distinct classes
Or if you want to risk, purge the class, which doesn't contain the methode, which we really use.
I hope that has clarified this often asked question.
I removed Android dependencies from build path and it worked.
This error happened to me when in my app's project I referenced a Library project in my Eclipse workspace (in my case the Facebook SDK) and at the same time included the Facebook SDK as a jar in the libs folder. Removing the library reference but keeping the jar in the libs folder removed the error.
I had same problem. I had to delete the .apk file and then it worked.
For me I deleted android-support-v4.jar from lib folder and also removed from build path.
Right click on project and go to build Path>configuration build path
Select library tab and click on support-v4 library and click on remove
Click on OK
and then clean your project and run it will work :-)
In case anyone else bangs their head on this issue like I just did:
My case involved a chain of library projects. Simply doing a project clean on all of the libraries fixed everything
I found below solution in eclipse...hope it works for you :)
Right click on the Project Name
Select Java Build Path, go to the tab Order and Export
Unchecked your .jar library's
This problem occurs when a same library is added into your project multiple times. If you haven't added the library multiple times intentionaly, check out the dependency/private libraries of the libraries you have added in your project, most probably they have already included a library which is causing this conflict.
I was also struggling to find this is issue. In my case what happened is while copying the apk to email (drag drop) - by mistake the apk was pasted in src folder in one of the packages.
After removing the apk from source folder it worked fine.
I had this problem in Intellij and it was because the ActionBarSherlock library I added to my project defined the android-support-v4.jar as a compile dependency and this jar was already included in my project so there were multiple copies/version of DEX at compile time.
The solution was to change the ActionBarSherlock module dependency for this jar to be Runtime instead of compile, as my project was already providing it.
For me the issue was that, i had added a lib project(autobahn lib) earlier and later switched the to Jar file of the same library.Though i had removed references to the older library project, i was getting this error.
Following all the answers here i checked the build path etc. But i haven't added these libs to build path manually. So i had nothing to remove.
Finally came across this folder.
bin/dexedLibs
I noticed that there were two jar files with the same name corresponding to autobahn Android which was causing the conflict. So i deleted all the jar files in the dexedLibs folder and rebuild the project. That resolved the issue.
To add the myriad of other potential sources... I had updated all the libraries in my project's lib folder but then Eclipse "helpfully" reinstalled all the original libraries. There was no longer any reference inside Eclipse to these libraries but the external dex-maker program just grabbed all the files in the lib directory and thus got two versions of several library .jar files.
git status identified the new files and git clean -f got rid of them for me (though I sometimes had to wait or restart Eclipse on Windows because it still had the files open from the copy).
ULTRA simple solution and finest:
Remove everything in Right Click Main Project's Folder -> Properties -> Java Build Path except Android X.Y (where X.Y is the version in android). Clean, and Build. Done!
Make sure before of that to have a single android-support-v4.jar.
If you are using cordova, try cordova clean command

Stuck with first time java for android

guys, with my friend started working on a school project - developing a java app for android. He started it, now it's my turn to do my job, so i got the code he already has, set up Android SDK for Eclipse and downloaded all the neccessary files and packages, but it still gives me errors and I can't even run the project.
One of the errors (the main one, I think) is that it can't import android.support.v7.app.ActionBarActivity
If anyone knows what can I do (I've tried all kinds of solutions from the internet, but none work) I would be very grateful.
Here is a screenshot of the code
http://s17.postimg.org/8aw952lha/Capture.jpg
See if you have imported the ActionBar project to your Eclipse workspace, also, right click on your project->properties->android and check that you have referenced/linked the ActionBar project there.
If you are using a repository without the proper ignore files it is possible that you have imported your partners configurations and then have the references to the auxiliary projects broken (you just need to update that).
Hope it helps.
android.support.v7.app.ActionBarActivity is a support library. This allows older versions of Android (before native support for an action bar was available) to use the action bar.
Since you are having difficulty importing it, I'd assume you do not have the support library installed.
Full instructions are available here:
http://developer.android.com/tools/support-library/setup.html
A snippet for adding support libraries to Eclipse:
Make sure you have downloaded the Android Support Library using the SDK Manager.
Create a libs/ directory in the root of your application project.
Copy the JAR file from your Android SDK installation directory (e.g., /extras/android/support/v4/android-support-v4.jar) into your application's project libs/ directory.
Right click the JAR file and select Build Path > Add to Build Path.

Java - Android - NoClassDefFoundError - "Could not find class" error in Logcat

First of all, I realise that similar questions have been posted a lot here. But I've been through all of the answers I can find to similar problems, and nothing has worked yet, so was wondering if someone could help me.
I'm trying to develop a simple chat app with an Android client and a server app sitting running on my laptop. This includes a regular Java "common" project that holds the class that is used to pass messages via the socket.
First I tried to reference the "common" project in the Android project, but after a bit of reading abandoned that idea.
Now I have exported the jar file for the common project, and imported it into my Android project by copying it into the "libs" folder, and then selecting Build Path > Add To Build Path. I have also gone to Properties > Java Build Path > Order and Export and checked the library and moved it to the top of the order.
I have also moved the "gen" project above the "src" one in that build order.
Android Private Libraries is also checked. Everything is checked.
When I debug as an Android Application to my Samsung S3, I see a "Could not find class error" in logcat when advancing to the Activity that contains a reference to a class in the "common" project. Stepping through to the point where a class in the "common" project is referenced then causes a ClassNotFoundException to be thrown.
If I try to put the name of the library in the Android Manifest, like:
<uses-library android:name="com.johndarv.chatproj.common" />
I get:
Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY
Please check logcat output for more details.
Launch canceled!
Upon trying to install.
I have the following versions:
Eclipse Standard SDK 2.0.0
Android SDK 22.3
Android project is compiled with Android 4.2.2.
Any help would be much appreciated! If I can give any more info that would be useful, please ask!
The uses-library tag means that your app expects the library to be available on the system. This is to prevent installation on devices which do not have some expected third-party software installed. Consider phone manufacturer who ships his devices with some specific api.
So this is not your case. Forget about this tag this time.
And as to your problem. The jar is not exported into the apk.
Ensure in Project Settings > Java Build Path > Order and Export that the library jar is checked to be exported.
If you put a jar into /libs dir of android project it is automatically added to the build path. You do not need to do this manually (as you did). Then you can see it (this jar) under Android Libraries entry in under Project Settings > Java Build Path > Libraries. This entry is also checked as exported (by default in android project) in Order and Export tab.
Maybe your problm occurs due to the fact that the jar is actually exported twice (once manually and once as private library). Just remove manually added entry from build path. You will have it added once - but to be honest I do not expect this caused the problem. But for sure the problem is in your project settings. Maybe paste a screenshot with Java Build Path > Order and Export and Java Build Path > Libraries.
I managed to solve this by deleting the common project and then creating a new Java project with "Use execution environment" set to Java SE 1.6. And rewriting (copy-pasting) the old classes.
There must have been something wrong with my previous project, and looks like it was the Java version used to compile. I had tried to set the compliance version to 1.6 on the old project. In any case, creating a whole new 1.6 project, pasting the classes in, re-exporting, and copying into my Android project did the trick.
Thanks to everyone who tried to answer this for your help. Hope someone finds the above useful one day!

Android : source not found [duplicate]

While debugging a java app in eclipse I receive a "Source not found" error in two cases:
Stepping in to a file in a different project which is already imported
Stepping in to a file in an installed maven repository
The files are there, but eclipse won't step into them, instead it shows a button to "attach source"
I tried attaching (which opened a dialog to define a variable?!) and eclipse did jump to the file, but the debugger could not inspect any variables there. Also manually attaching the source for each dependency isn't practical, as in my case there are thousands of dependency files.
Why is this happening, and how can it be resolved?
Just 3 steps to configuration Eclipse IDE:
Note: After updating the Source Lookup paths, you'll have to stop and restart your debug session. Otherwise, the file with the missing source will continue to show "missing source".
Edit Source Lookup
Select the Edit Source Lookup... command [ Edit Source Lookup ] to open the Source Path Dialog, which allows you to make changes to the source lookup path of the selected debug target.
IMPORTANT Restart Eclipse after this last step.
Eclipse debugging works with the class actually loaded by the program.
The symptoms you describe sounds like the class in question was not found in the project, but in a distribution jar without debug info found before the project you are working with.
This can happen for several reasons but have a look at the location where the classes showing this behaviour is found (look in the navigation pane to identify it). You will most likely need to change the build path of the project to avoid using this jar and have the JVM use the project instead.
EDIT: Note that as of 2018 it is common to use a build framework like Maven, where the build path is managed by the m2e plugin so this problem should be very less frequent than when the question was asked. If you use Maven and m2e, make sure to enable Preferences / Maven / "Download Artifact Sources" or right-click the project, Maven / "Download Sources".
The symptoms perfectly describes the case when the found class doesn't have associated (or assigned) source.
You can associate the sources for JDK classes in Preferences > Java > Installed JRE. If JRE (not JDK) is detected as default JRE to be used, then your JDK classes won't have attached sources. Note that, not all of the JDK classes have provided sources, some of them are distributed in binary form only.
Classes from project's build path, added manually requires that you manually attach the associated source. The source can reside in a zip or jar file, in the workspace or in the filesystem. Eclipse will scan the zip, so your sources doesn't have to be in the root of the archive file, for example.
Classes, from dependencies coming from another plugins (maven, PDE, etc.). In this case, it is up to the plugin how the source will be provided.
PDE will require that each plugin have corresponding XXX.source bundle, which contains the source of the plugin. More information can be found here and here.
m2eclipse can fetch sources and javadocs for Maven dependencies if they are available. This feature should be enabled m2eclipse preferences (the option was named something like "Download source and javadocs".
For other plugins, you'll need to consult their documentation
Classes, which are loaded from your project are automatically matched with the sources from the project.
But what if Eclipse still suggest that you attach source, even if I correctly set my classes and their sources:
This almost always means that Eclipse is finding the class from different place than you expect. Inspect your source lookup path to see where it might get the wrong class. Update the path accordingly to your findings.
Eclipse doesn't find anything at all, when breakpoint is hit:
This happens, when you are source lookup path doesn't contain the class, which is currently loaded in the runtime. Even if the class is in the workspace, it can be invisible to the launch configuration, because Eclipse follows the source lookup path strictly and attaches only the dependencies of the project, which is currently debugged.
An exception is the debugging bundles in PDE. In this case, because the runtime is composed from multiple projects, which doesn't have to declare dependencies on one another, Eclipse will automatically find the class in the workspace, even if it is not available in the source lookup path.
I cannot see the variables when I hit a breakpoint or it just opens the source, but doesn't select the breakpoint line:
This means that in the runtime, either the JVM or the classes themselves doesn't have the necessary debug information. Each time classes are compiled, debug information can be attached. To reduce the storage space of the classes, sometimes this information is omitted, which makes debugging such code a pain. Your only chance is to try and recompile with debug enabled.
Eclipse source viewer shows different lines than those that are actually executed:
It sometimes can show that empty space is executed as well. This means that your sources doesn't match your runtime version of the classes. Even if you think that this is not possible, it is, so make sure you setup the correct sources. Or your runtime match your latest changes, depending on what are you trying to do.
From http://www.coderanch.com/t/587493/vc/Debugging-Eclipse-Source
"When running in debug mode, right click on the running thread (in threads tab) and select Edit Source Lookup. At this point, you should be able to add the necessary project/jar which contains your source code."
I added my current project in this way, and it solved my problem
I had similar problem with my eclipse maven project. I fought with this issue quite a long time then I tried to rebuild project with
mvn clean eclipse:eclipse
and it helped.
Note: Using this approach will confuse the m2e plugin since the two approaches are very different. m2e adds a virtual node to your project called "Maven Dependencies" and asks Maven to add all dependencies there.
mvn eclipse:eclipse, on the other hand, will create a lot of individual entries in the file .classpath. Eclipse will handle them as if you manually added JARs to your project.
Unless you know how the classpath in Eclipse works, this approach is not recommended.
I was facing the same issue,I followed the bellow steps.
Window => Preferences => Java => Installed JREs,
You see in the above screen Jre1.8.0_12 is selected.
select the JRE you are using and click Edit. Now You should see the bellow screen.
Click on the directory, browse for Jdk, It should look like bellow screen.
click ok, and its done
I had the problem that my Eclipse was not debugging the source code of my project. I was getting a blank page with "Source code node found".
Please click the Attach source code button. Then delete the "default" folder then click add and go to your project location and attach. This worked for me
Remove the existing Debug Configuration and create a new one. That should resolve the problem.
None of the mentioned answer worked for me.
To resolve this issue i have to follow bellow steps:
Right click on Java HotSpot(TM) 64 Bit server.
Select "Edit Source Lookup".
Click on "Add".
Select "File System Directory" instead of Java project.
Select Root directory of your project.
Check "Search Subfolders".
Click Ok ok ok.
Thanks.
Click -> Edit Source Lookup Path
after then
Click -> Add finally select Java project and select project path.
Source: https://www.youtube.com/watch?v=IGIKPY6q1Qw
In my case, even after Editing source lookup and Adding project, it didn't worked. I configured the Build path of the project.
After that, I selected JRE System Library and it worked.
Evidently, Eclipse does not automatically know where the source code for the dependent jars are. It is not clear why debugger could not inspect variables once the source was attached. One possibility is incorrect/incompatible source.
Assuming you have a maven project and the sources of the dependencies are downloaded and available in the local repository, you may want to install m2eclipse, the maven eclipse plugin and see if that helps in addressing your issue.
You might have source code of a dependency accessible to Eclipse. But Eclipse does not know for source code for code that is dynamically loaded. E.g. through Maven.
In case of Maven, I recommend that you use run-jetty-run plugin:
http://code.google.com/p/run-jetty-run/
As a workaround you can also connect to a running JVM with the debugger and you will see the code.
Alternatively you can use Dynamic Source Lookup plugin for Eclipse from here:
https://github.com/ifedorenko/com.ifedorenko.m2e.sourcelookup
Unfortunately it didn't helped me as it has issues with Windows paths with spaces.
I have filled an enhancement request on Eclipse Bugzilla and if you agree this issue "Source not found" should vanish forever, please vote for it here:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=384065
Thanks!
Sasa
In my case in "Attach Source", I added the other maven project directory in the "Source Attachment Configuration" panel. Adding the latest version jar from the m2 repository din't work. All the classes from the other maven project failed to open.
Here test was my other maven project containing all the java sources.
I had the very same problem. In my case, I've disabled Window-Preferences-Java-Debug [Suspend execution on uncaught exceptions]. Then, the console showed me the correct error: my MySql user hadn't privileges to access the database. According to this topic.
Info: This is a possible solution, when you use maven (pom.xml) with couple of projects.
If you are working with maven, make sure what version you are taking inside the according pom.xml (e. g. 1.0.1-SNAPSHOT ).
It might be possible that your code is up-to-date, but your pom.xml dependencies are still taking the old JAR's/Snapshots (with the old code).
Finding the problem:
Try to debug the according file.
Therefore, set a breakpoint in the relevant code area.
When "source not found" appears, make sure to bind in the right project (where the .java file can be found).
The compile .class file opens up in the IDE editor.
Click "Link with Editor" to find the according JAR/Snapshot.
Now make sure that this JAR is the most recent one. Possibly there is a newer one. In that case, write the most recent version number in the pom.xml.
Then do a maven update and build (e. g. "mvn clean install -U") in the right project directory.
If you are on eclipse or STS please install and Use GC(GrepCode Plugin) ,some time you don't need to attach the source .zip file into your project path so GrepCode works fine for you.
I've had a related issue in connection with Glassfish server debugging in Eclipse.
This was brought about by loading the source code from a different repository (changing from SVN to GitHub). In the process, the wrong compiled classes were used by the Glassfish server and hence, the source and run time would be out of sync with break points appearing on empty lines.
To solve this, rename or delete the top folder of the classes directory and Glassfish will recreate the whole class directory tree including updating the class files with the correctly compiled version.
The classes directory is located in: /workspace/glassfish3122eclipsedefaultdomain/eclipseApps/< your Web Application>/WEB-INF/classes
In my case with tomcat projects I have checked project here:
Window - Preferences - Tomcat - Source Path - Add java projects to source path
In my case the Maven version of the other referenced project didn't match the version of the test project. Once they were the same, the problem disappeared.
When running in debug mode, click Edit Source Lookup after suspended from thread. At this point, we should be able to add the necessary project/jar which contains your source code.
After I added my current project in this way, and it solved my problem. Thanks
If you want to attach source code to any JAR by auto-downloading, try using this Eclipse plugin Java Source Attacher
I had this problem while working on java code to do process on a excel file containing a data set, then convert it to .csv file, i tried answers to this post, but they did not work.
the problem was the jar files themselves. after downloading needed jar files one by one(older releases) and add them to my project, "source not found" error vanished.
maybe you can check your jar files.
hope this would help.
this worked for me
right click on project -> Properties -> Deployment Assembly -> add your jar
Go to Debug configuration in eclipse and use below goal to run your application.
-Dmaven.surefire.debug
e.g
-Dmaven.surefire.debug exec:java
Well, here's what worked for me. I tried every possible solution on StackOverflow that there was. I tried changing my source location in the debug menu, I installed the m2e Eclipse plugin, I changed from embedded Maven, and I installed the run-jetty-run and nothing worked. Now, I will caveat that I was not trying to view an external person's source code, I just wanted to see my OWN code, but every time I "stepped in" to my methods that I wrote that were in MY project, I got the "Source now found" error.
After finally asking an expert, my issue was that the first thing Eclipse was doing was calling a ClassLoader, which you can see from the debug stack. All I had to do was F6 (step over) and then it took me back to my original call and then F5 (step in). And there was my code. Sigh...such a simple fix but an hour wasted.
For beginners,
There is a possibility that the jar file is a part of the project which you have not yet included in the Eclipse workspace.
For that, you need to know the project name of the jar file.
Say for example, its abc-18.0.0-SNAPSHOT.jar, it means that the project you are supposed to include in your workspace is abc.
I had the same issue with eclipse 2019-03 (4.11.0) and I was only able to solve this by doing the debugging via remote debugging instead of directly launching it in debug mode.
Attach source -> Add -> External Archive -> select the jar -> open -> done
the catch is look for the sources jar and attach this jar.
for example the jar ends with "-sources" Stax2-api-3.4.1-sources
sometimes these thing happens because of the version also like if you are using latest
version in that case it may arise try to use older version it will work.

android-support-v4.jar isn't importing correctly in Eclipse

I'm trying to get an app to compile that uses the android-support-v4.jar and the Fragmentation classes it contains, but I keep getting messages whenever I try to compile that there are errors in the code. All of the errors have to do with different Fragmentation classes that are in the .JAR. I have tried ctrl-clicking the project folder and then selecting Android Tools -> Add Compatibility Library and I keep getting this error:
[2011-12-20 11:55:31 - Android Compatibility JAR not found:]
/Applications/eclipse/Eclipse.app/Contents/MacOS/v4/android-support-v4.jar
Why would it be looking for the .JAR in Eclipse's Package Contents? I've gone into the project properties and went to the Java Build Path, and imported the .JAR from the MainActivity/libs folder, that didn't work, and then I tried to import it from my SDK directory, and that didn't work. I've fixed the project properties and cleaned and built it countless times, I've restarted Eclipse, my computer, re-downloaded and installed Eclipse, the Android SDK's and ADT and still nothing. I am completely stumped.
Edit
I've gone through the build path and imported the .JAR from both the MainActivity/libs and my SDK directory. For the hell of it I added the .JAR in the directory that keeps appearing in the errors and that hasn't worked. What's making Eclipse look for it in it's Application Package Contents?
Update
So after tinkering the project contents aren't showing any errors but the MainActivity folder still says that there is one and I still can't compile.
Like nyah:
Revision
So I think the question may be "Why is Eclipse looking for the .JAR in the Eclipse Application's package contents instead of the libs directory of the project or the Android SDK directory that I used to import it as an external .JAR?"
Update #2
I am only getting one error now after tinkering, it's on this method:
#Override
public MenuItem setOnActionExpandListener(OnActionExpandListener onActionExpandListener) {
// Noop
return this;
}
The Quick Fix says that I should delete the #Override annotation but that method must override a super class method.
These are the errors that it shows:
Multiple markers at this line
- The method setOnActionExpandListener(MenuItem.OnActionExpandListener) of type SimpleMenuItem must override a superclass method
- implements android.view.MenuItem.setOnActionExpandListener
Looks like it is looking for jar here :/Applications/eclipse/Eclipse.app/Contents/MacOS/v4/android-support-v4.jar
android-support-v4.jar is found in <sdk>/extras/android/compatibility/v4
Please make sure you add this as an external jar in the java build path
I could solve this problem by
1- delete "android-support-v4.jar" from lib
2- right click on the name of the project choose "Android Tools" and "Add Support Library"
If this is still not solved:
Like already said, in Eclipse go to your Project Properties > Java Build Path > Libs > Add External and get the one from the adk directory.
Also set up Java 1.6 as your default compile version if you already haven't. This should solve the Override Errors you described.
It turns out that my Debug Certificate had expired so I just needed to delete ~/.android/debug.keystore and restart Eclipse and everything worked.
I realize that this question has been answered, but this is a known issue that is supposed to be fixed in the ADT-17 plugin release according to comment 9 here: http://code.google.com/p/android/issues/detail?id=21488
In addition, people who have this problem can copy the compatibility JAR to the location it says it can't find it. Clearly it's looking in the wrong place (since it's checking the Eclipse directory rather than the android-sdk directory), so the simple fix, for now, is simply to put the package where it wants to find it, even though it doesn't belong.
For me it was as simple as copying the v4 directory within C:/android-sdk/extras/android/support/ into the C:/eclipse/ directory.
I had the same problem running in Ubuntu. Go to Tools->Options.
Check Force https://... to http://
Open Android SDK Manager. Check Extras->Android Support Library.
Something similar happened to me. At the top of MainActivity.java I had the next imports giving errors:
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
In each of the lines on the left they had the light bulb making some suggestions. If you click on it, one of the options will be "Fix project setup". You then will be able to choose between several options for fixing the imports, you should choose the one that specifies the android-support-v4.jar.
Right click on ur project --> select android tools --> select add support library and simply installed the supporting libraries.
Do you try not to do Android Tools -> Add Compatibility Library, and only add the jar in java build path library?.
I use this jar library of this way and it works without any problem.
I had the same problem.
Under the project properties:Java Build Path:Order and Export tab, the box next to android-support-v4.jar wasn't checked. I checked the box, and the error went away.
Another caveat was running Android SDK Manager in Windows 7 without administrator privileges. It would try to install support package, but would always fail, and the actual package never got downloaded to
C:\Program Files (x86)\Android\android-sdk\extras\android\support\v4\android-support-v4.jar
Solution: Make sure that you enter the same API for "Target SDK" and "Compile with" during Android project creation (or in the Manifest file once created).

Categories