Android import project errors - java

Hey everyone, I'm a beginner, so I'll try my best to explain this problem succinctly.
Basically, a friend of mine and I were playing around with the Android SDK, editing a simple RSS reader. We could launch it in the emulator and even install it on our real devices.
Fast forward a few days, I'm trying to import the exact same code that was working a few days earlier into Eclipse on my laptop.
I tried both importing and new project from existing source. Both return these new errors that we never had originally.
I got an error that involved the auto generated "R" file, but I have solved this. Now, I'm getting 3 errors that I have never had before -
The method onClick(View) of type new View.OnClickListener(){} must override a superclass method - displayed twice ( 2 different lines)
The method onTabChanged(String) of type new TabHost.OnTabChangeListener(){} must override a superclass method
My question is this - What would cause the these discrepancies between importing/running on my friends computer and mine?
Also, we are both using the latest version of Java/Eclipse
Thanks in advance for any insight.

Are you building using the Java 1.5 or 1.6 tools? 1.6 allows the #Override annotation on interface methods, 1.5 does not.

Related

LWJGL GLFW hangs on native glfwInit call

I originally posted this question on GameDev stackexchange however I'll also ask the question here to try and get more outreach, especially since I wasn't sure my problem was specific to game development since it's a problem with a Java native call.
For the past months I've been working on creating my own game engine for personal use in LWJGL using pieces here and there, especially from developer ThinMatrix's rightfully credited code, to learn as much as I can while building it. Only recently there has been strange behavior happening when I launch the engine from IntelliJ for testing:
After about 6-10 individual times I click run, all subsequent runs suddenly take about 60 seconds for the window to appear.
Whenever I restart my PC this hanging resets and I have another 6-10 runs before it hangs everytime again.
I located the issue to glfwInit, more specifically at the call to the native method:
#NativeType("int")
public static boolean glfwInit() {
long __functionAddress = Functions.Init;
return invokeI(__functionAddress) != 0; // Right here
}
I also noticed that this issue only started when I attempted to implement text support in my engine using the STBTrueType library. It was perfectly fine before that. I tried removing the TrueType code but it didn't fix it.
Here's a list of things I've tried:
Clearing my temp folder in case a buggy or corrupted file was present.
Recompiling and rebuilding the entire LWJGL jars twice.
Building glfw.dll from the GLFW sources and replacing the glfw.dll in the native jars with the former.
Reinstalling Java and actually upgrading JDK versions (from 13.0.2 to 14.0.2)
Switching IDEs even if I suspected it wouldn't work.
Updating my NVIDIA drivers, and reinstalling them.
I'm quite confused as to what it could be, and I'd be more than happy to share code, thread dumps, or debug info if you deem it necessary. Here is the Github repository with the latest, "faulty" code (fault in quotes because I'm not too sure the code is the problem.)
Thank you very much for any guidance.
P.S: Please tell me if this is better asked in StackOverflow instead of here.
So I fixed the issue, it turns out it wasn't even related to anything to do with programming, or STBTrueType, or the library itself. The problem was as pointed out in this StackOverflow post, where this hanging behavior was due to a faulty driver or, in my case, my keyboard USB being plugged in the "wrong" USB port. I moved my computer at the same time I started working on text in my engine, hence why I wrongly linked the issue with the TrueType library. If you're having the same issue, look at the aforementioned post or if that doesn't work, look for a peripheral that might cause interference.

Android Studio problem: Unused Java instance variable marked as used

I am using Android Studio 3.2.1 Build #AI-181.5540.7.32.5056338 (linux version). Although this problem might also appear in Intellij Idea which I have not tested. The problem is whenever I name my instance variables by certain names (like place,time,date) they are instantly marked as used right when I declare them! Below is a screenshot of the problem:
Here I just opened the default Hello World project and typed some declarations. I have not touched anything in the project other than this. Imagine how much of a nightmare would be this kind of misinformation for big projects! Can anyone here solve this or suggest any workaround (other than changing names of those variables)? (And also if you feel to downvote then atleast comment first)

Basic Android Project: alternating cannot be resolved or is not a field/R cannot be resolved into a variable errors

I am new to Android Development/Java Programming/Eclipse so please bear with me. I've been going through the Android Developer Training (developer.android.com/training) and the Hello Android book by Ed Burnette and keep running into a problem that is making it difficult to move forward. I'll do my best to describe it and am hoping that the community can help me resolve it.
I began seeing this issue with the Android Developer Training (around Adding the Action Bar -> Adding Action Buttons) and it became impossible to circumvent at Hello Android's 3.3 Creating Opening Screen when I tried adding the Sudoku buttons. The only change I made when going through Hello Android was adding the Android Development Toolkit (ADT) for Eclipse. I don't recall this being a required download going through the Android Developer Training page so I am wondering if its addition could have contributed to the problem.
The issue that I keep running into is that when I go to build the project, Eclipse keeps telling me:
action_settings cannot be resolved or is not a field
activity_sudoku cannot be resolved or is not a field
container cannot be resolved or is not a field
fragment_sudoku cannot be resolved or is not a field
sudoku cannot be resolved or is not a field
I've tried several fixes that I saw on in the forum including deleting the import.android.R from the sudoku.java file in my src folder but that brings up a bunch of errors that say R cannot be resolved into a variable. I've tried cleaning and rebuilding and restarting Eclipse, methods that occasionally worked before Hello Android and the plugin, but keep getting the same errors. I've also tried setting to Android 3.0 and higher thinking that might be an issue but there was no change. Occasionally I get another error regarding not being able to find the path for a container but I've been playing around with the IDE for 15 minutes and can't seem to get it to pop up again.
I could really use some help on this.
Hope to hear from you,
Yusif Nurizade
This solution may, first and foremost, demonastrate how green I am with Android programming but I believe I found the solution.
Initially following the Android Developer Tutorial, I downloaded the latest versions - 18, 19, 20, etc. When I was creating the project, however, I was specifying much early versions for compatibility; all the way down to 7 or 8. I looked into this because I remembered seeing a message from the IDE regarding the Action Bar and how some commands weren't supported on Version X.
I went back and downloaded all the versions down to 7 or 8 and set the compatibility accordingly. The example now works with minimal other changes. I realize that I may be overlooking something but this is the only major change I made and it seems to have done the trick.
Hopefully this will help other newbies!
Yusif Nurizade

Code is not compiling in Netbeans using JavaFx implementing Controllers passing parameters

I was working this afternoon in my project without problems. Before come home I did a commit to my svn to continues it in home, but now when I try to run it shows a code error that hadn't shown before. The Following code it's supposed to initiate new scene using controllers and passing parameters. Error:
Someone knows what is happening? If you say "The code is wrong" it's not possible cause I was using the exactily same code in my work.
Detail, in the afternoon i was using Mac OS and now I'm using Windows. And IDE is Netbeans in booth places
My problem was not about code, actually the code is right.
The problem ocurred because my Netbeans was pointing to a old version of JavaFX. The way to fix it was to uninstall everything about java from my computer and after reinstall with the newer versions of JDK, JavaFx and Netbeans.
Cast your loaders to their appropriate types. For the first cast it to the Login Controller and for the second cast it to the MainViewController.
NetBeans only see's an abstract Object being returned, even though what is actually being returned is a little more specific. I'm not sure why this happened when you moved from one platform to the next (I assume you have the same version and everything), but some compliers will catch this as an error and others will not. Technically there is no error, just questionable results.

Android: Master detail project has errors right after creation

I have the android 4.1 and 4.0 SDK installed on my laptop. I've done plenty of projects just using a blank activity, but when I decided to try a "master detail flow" example from within Eclipse (create new Android project, select MasterDetailFlow) the other day it wouldn't even let me build. I have errors right off the bat. Surely this can't be right? Here are the errors:
(1)The method onItemSelected(String) of type ItemListActivity must override a superclass method ItemListActivity.java /Master Detail/src/com/example/master/detail line 39 Java Problem
(2)The method onItemSelected(String) of type new ItemListFragment.Callbacks(){} must override a superclass method ItemListFragment.java /Master Detail/src/com/example/master/detail line 27 Java Problem
I'd like to try and use the master detail forms so I can understand more advanced android layouts. Could anyone point me into a better direction with that as well? Thanks!
Ugh, that's a pain, but it's a pretty simple solution. The rules for when you should/shouldn't use #Override switched from Java 5 to Java 6, so depending on Eclipse's default JDK it'll sometimes yell at you when #Override isn't there but should be, or vice versa.
Set the compiler level in Eclipse to at least JDK 6 and the errors will magically disappear :)

Categories