I'm working on a little app and retrieving data from a server. In debug mode I can see the properly formatted JSON string is received and stored in my var.
Right after I try instantiating a Gson object ( using Gson gson = new Gson(); it dies on this line)
and it just dies... I can't seem to get any output in log cat so I can't see the exception being thrown. I've just migrated from windows to Ubuntu (64 bit) so it's quite possible I'm missing something in my set up but everything else works fine and I'm finding it hard to trace why it happens...
if there is a force close the stacktrace should 100% show up in logcat.
otherwise this is a simple object construction so maybe check the buildpath for the libraries. also try cleaning the project but your code should be working...
Okay, turns out this is related to a known issue with eclipse and mylyn.
Moving the mylyn.jar files out of eclipse's plugin folder seems to solve the issue.
(Gson object is being constructed fine and I'm making use of it now...exception was unsupportedexception when i was trying to remove items from an arraylist...odd because this is done several stages before constructing the gson object)
Although this was not entirely the same issue (because there was output in logcat...just wouldn't show anything related to errors/exceptions, and that's in verbose mode and others).
More info:
http://groups.google.com/group/android-developers/browse_thread/thread/c64de09595795538/8e577a1e52b26c73?lnk=gst&q=eclipse+19%25#8e577a1e52b26c73
Why doesn't logcat show anything in my Android?
http://code.google.com/p/android/issues/detail?id=1808
Very weird bug, putting the mylyn jars back in the folder and everything works. So the process then:
Open path/to/eclipse/plugin/
cut all *mylyn.jar files
paste them into a temporary folder outside of the eclipse directory.
start/restart eclipse and test that log cat works
All is well? Some feature such as code completion probably isn't working now... Move the mylyn.jar files back to the plugin folder (I'm not sure if it matters whether eclipse is opened or not when you move them back in but it was running when i did it.)
restart eclipse and you should be good to go...
Related
So in the past days i've decompiled minecraft 1.12.2 using mcp to make an "own" client. I ran it from eclipse and all was working just fine. But once i exported it, added the needed JSON file and started it from the minecraft launcher, it resulted the following error:
Exception in thread "Client thread" java.lang.NoSuchMethodError: org.apache.logging.log4j.Logger.info(Ljava/lang/String;Ljava/lang/Object;)V
at net.minecraft.client.Minecraft.<init>(Minecraft.java:420)
at net.minecraft.client.main.Main.main(Main.java:115)
In my opinion that'a a bit strange, because when I ran it from eclipse that error did NOT occur.
I was thinking about adding the logger in the specific JSON file for the version but I do not know how to do it. I took the JSON file from a video where I expected my problem to be solved, made some changes, but it didn't. I also put the folder containing the logger-jar (org.apache....) in the client jar, but still no success.
Also i just decompiled 1.12.2 and recompiled it right away to see if i had messed up my code some how.
I hope someone can help.
This means at runtime you have a class that is different than what you had at compile time. You should try unzipping the jar and searching for the class file. It sounds like you need to potentially remove it and replace it with your own version.
Thanks to all who viewed an wanted to help!
Now I found an other way to use it. I wanted to export it to test
it on my server. But instead I used my account credentials to log in directly from eclipse.
:)
I have re-started Eclipse, re-run the application numerous times, and saved all of my files in my application. In my .xml, I have gotten rid of a button.
The .xml is inflated in my .java file. However, when I run my application on the Android emulator, it keeps showing the button that I deleted.
reinstall the application, clean the project in eclipse.
One possibility is your emulator is not connected to the ADB (Android Debug Bridge)
To check just do:
cd C:\Program Files (x86)\Android\android-sdk\platform-tools
adb devices
You should see
List of devices attached
emulator-5554 device
If you don't see this, manually kill the adb.exe process (DON'T kill your emulator).
Then manually run adb.exe again.
When you do adb devices you should now see your emulator. If you close/kill your emulator you may have to repeat the process again.
I would have thought that restarting Eclipse would have had the same effect anyway, but for what it's worth, always try Project -> Clean in situations like this.
Clean the project and then run.
OK - I tried all this and it did not work (but I did resolve the problem...).
My project is very simple, as I am a complete newbie and had only created a mock up of the app - a simple interface and adjusted the strings XML file. None the less, I wasted a couple of hours trying to fix this damn problem. In the end, I simply generated a new project and ported all my work over. This took 10 mins and worked perfectly.
To try to learn why this happened, I repreated the steps that seemed to have caused the problem (clearing all projects, and then building them all again) - having copied all the code fromt he original project (including the manifest). I could not break it again, so am none the wiser about what caused it.
A more complicated project might be more of a challenge, but I thought I would post in any case, as I wasted a lot of time trying all these other things without sucess.
Uninstall the application from Setting->Application->Manage Application->Select Your app->Uninstall. and then run.It will work
To detail Rasel's answer (in addition to Project...Clean) you can also go to a shell and type adb uninstall com.example.applicationname.
The problem happened to me when I imported the project using the orginal files in Eclipse. It worked after I imported the projekt into the eclipse workspace as a copy
I had the same problem in Android Studio. When I added an imageButton it was visible in preview tab of Android Studio, but not in the emulator. I tried almost every solution mentioned in Stack Overflow for similar situation, but I didn't succeed. One of answers said that you should create a new project and copy your files into it, but this solution had a huge cost for me and I didn't want to try it. Finally I renamed my layout file in the onCreateView method:
View view = inflater.inflate(R.layout.fragment_story_edition, container, false);
Then I created a new layout resource and left it empty and ran the project in order to get an error. After that error, I copied the content of my original layout file to my new made layout file, and the problem was solved.
I keep getting this when trying to start a new project
ERROR: Unable to open class file C:\Users\Levi\Desktop\Android\workspace\Droid1\gen\com\androidbook\droid1\R.java: No such file or directory
I tried changing preferences to alter build path to project, but it still wouldnt work,,,
Is subfolder on desktop a bad place to install Eclipse?
Clean works sometimes and should be tried. I also find that blowing away the gen directory and refreshing will cause it be to rebuilt. Try that as well.
However, sometimes even that doesn't work and I've been forced to remove the project from Eclipse and then re-import it. This, unfortunately, works for me every time if the above has not.
Good luck.
Im also getting that error, running a Project->Clean in Eclipse helps for me.
Project->Clean should certainly fix this (unless your resources won't compile for some seperate reason).
I remember that the first time I ran Eclipse (in mid 2009, can't remember if it was Galileo or Ganymede or whatever) on Windows Vista, it presented several problems that were eventually traced to Eclipse itself being in a directory whose path contained a space...
Usually, the above tips (refresh, clean) work for me. But lately I had a very persistant instance of this error, which was caused by something else:
One of the layout .xml files in res/layout contained a reference to a custom view (org.company.project1.MyView). However, I had changed the package path (org.company.project2.MyView), so the reference had become invalid.
Thus, if everything fails try browsing your layout .xml files for invalid custom element definitions.
Cheers
after spending hours trying to ultimatly discover the issue behind the Class Issue not being found, resolved,or directory not there issue....
sometimes yes the issue is due to a bad binary or xml... as sometime a clean will do the trick or a xml edit will solve the day.. when all else fails.... this may do it..
"create a new workspace"
go into the workspace.... and then
Switch to your old workspace... in the newly formed workspace...
this was my silver bullet. so frustrating to not have a solid answer.
using Version: Helios Service Release 2
Build id: 20110218-0911
I'm relatively new to Java, eclipse and android so this could be a completely silly question, but I'm going to ask it none the less.
I've got a project I'm learning with to test connecting to the flickr api and simply displaying recent images. I'm at the point now where I want to parse the JSON received from flickr. I've downloaded gson 1.4 and added the zip to the java build path through "add external jars." It's successfully loaded and I can see google-gson under referenced libraries in the package explorer. My problem is, when I try to use it, I simply get an error.
Gson gson = new Gson();
It highlights Gson and says that "Gson cannot be resolved to a type." What am I missing here? It worked once and has since stopped. I've tried removing the jars, cleaning the project and re-adding the jars but it still doesn't work.
Am I just completely noobing this up or is there another problem?
I'm not sure exactly why this worked but I extracted the zip and just added gson-1-4.jar and it appears to have worked.
Hooray!
Same problem occurred with me too. The solution is to download the entire gson package ie. google-gson-1.6-release.zip instead of stream only version ie google-gson-stream-1.6.jar. It works fine after you unzip the package and add the jars in your build path.
Cheers
Mudit
I am working on a team project in Java. One requirement is that we dynamically populate a drop-down menu of all classes that implement a certain interface. New classes can be added after compile time. To accomplish this we are using reflection.
Problem: All of the drop-down menus are blank on my system. I cannot for the life of me figure out why they are not populating. All other 5 team members have it working on their system.
Things I tired that didn't work:
1) Installing most recent eclipse (galileo) because rest team was using it
2) Re-install most recent java release (jdk1.6.0-17 and jre6)
3) Check PATH and JAVA_HOME variables
Any thoughts as to what else I can try or if something I did should have solved it and didn't? It is driving me crazy.
Edit:
I should have been clearer that we are developing in a team. We are using SVN for version control and we are all running the exact same source code. I even tried checking out a fresh copy of the entire tree from SVN, but I had the same issue with reflection on my system while it worked for teammates.
The team created an executable jar and that ran on everyone's system fine except for mine. Everything worked for me except the reflection bit.
You need to debug your application. This means you have to systematically explore possible causes of the problem. Here are some things that come to mind:
Could your GUI be failing rather than reflection? What if you output with System.out.println() rather than your menu?
Is your reflection code throwing an exception, and are you ignoring it?
Is your reflection code actually being called? Toss a println() in there to be sure!
Is the test for the interface suffering from a typo or similar error that's causing it to fail? Try finding classes that implement Serializable instead!
Is your reflection test running in the main thread and trying to update your GUI? You need to use SwingUtilities.invokeAndWait to get an update to the Swing worker thread.
You're working with Eclipse; Eclipse has a fantastic debugger. Set a breakpoint near where your main action is and then single step through the code.
PATH and JAVA_HOME won't help. PATH only affects dynamically-linked libraries ("native code"). JAVA_HOME is a scripting variable that happens to be used by some Java-based utilities like Ant and Tomcat; it means nothing to the Java runtime itself.
You need to be investigating the classpath, which should be specified by the -classpath option to the java command, in the Build Path in your Eclipse project properties, or in the Class-Path attribute of the main section of a JAR file if you're launching java with the -jar option.
From within your code, you should be able to list the contents of your classpath by examining the system property, "java.class.path"
System.out.println(System.getProperty("java.class.path"));
Problem solution:
Classpath leading to source code must have no spaces in it.
I am running windows XP and, for whatever reason, if the classpath that leads to the jar file or source code that is using reflection has any spaces in it, then the reflection fails.
I took the jar file that works for the rest of my team and ran it from C:\ on my system and the reflection worked perfectly fine.
I do not know why this is so please comment if you know what is happening.
Might be a long shot, but look for differences in security settings for you and your team mates. Article describing more details http://www.ibm.com/developerworks/library/j-dyn0603/ heading "Security and reflection"