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)
I've recently been attempting to set up SceneBuilder but suddenly my copy of Eclipse crashes pretty much instantly when I attempt to try and associate any external editor with a file type (not just XFXML). I've done some research and this seems to be the only page I can find talking about the issue, but I'm not sure how to take the advice therein.
I've linked the error log generated by these crashes. If anyone has experience something similar or has any idea how to go about troubleshooting this issue I'd greatly appreciate your input!
//I've included this code block to allow the pastebin link to work. There have
not been any issues with programming as the IDE won't operate as expected.
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
Okay so here's the jiff of it, I was changing the android API in the Android Manifest and the Android Manifest from the "bin" folder. I changed the API from 10 to 12 manually by removing the 0 and adding a 2. Now, when I go to save the project its giving me this error found in the image:
This is incredibly and extremely annoying not being able to find the problem. Yes, I am aware that there are other questions with this matter but I can't find anything that is useful/fixing my problem so I'm asking for help here. If anyone could help me fix my problem that would be beyond awesome! Also, if needed I can put some code. Something to take note is that there aren't any errors coming up in the LogCat but just this annoying pop-up.
It seems that the Android SDK doesn't compile my android app correctly. After building an app, I sometimes get seemingly random exceptions. The error goes away if I comment out the offending code, rebuild, uncomment the code, then rebuild again.
For instance, this code gave me a NullPointerException:
playButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
startActivityForResult(settings, PLAY_GAME);
}
});
There is nothing wrong this code! Yet adb logcat tells me it's the cause of an exception.
Commenting out this code, rebuilding, uncommenting and rebuilding, makes the error go away.
What is going on?
This is making developing for android particularly frustrating.
Update: As I pointed out before, these are seemingly random errors that go away once I uncomment/recompile/comment/recompile. So I can't reproduce the stacktrace. It was a NullPointerException if I remember correctly.
However, if it is indeed buggy programming, why is the app running fine now w/o ANY errors at all?
Whenever I make a significant change to the app (add a new resource, a new class, function, etc), old code that was working fine breaks. Why?
Update: Seriously guys, lay off on the hate. I feel like a stumbled on a Atheists vs Christian debate. Sorry to have insunated that android was at fault. Started a new question with the latest errors:
App Ran Fine, Now Breaking for Seemingly Unknown Reasons
Commenting out this code, rebuilding, uncommenting and rebuilding, makes the error go away.
This might seem to you like a bug in Android, but I suspect that the real problem is a threading / synchronization related bug in your code. For instance, playButton may be being used before it is initialized.
But we cannot really help you unless you show us the stack trace and identify the line(s) of code where the exception was thrown.
However, if it is indeed buggy programming, why is the app running fine now w/o ANY errors at all?
See above: it is most likely because you have a threading / synchronization issue. You need to be aware that different parts of an application with a GUI will run in different threads ... even if you didn't explicitly create those threads. There are rules you have to follow. If you don't follow those rules, bad things happen ... like exceptions that sometimes happen and sometimes don't happen, depending on which way the wind is blowing.
Could be that your PLAY_GAME activity is returning without a result, e.g., if you press the back button & it just stops without calling setResult().
No, as noted in several other places, sometimes the source and the bin get out of sync. I've noticed numerous times, specially when making changes to XML. The solution, for commandline users, is to remove the bin directory, and re-compile. Problem goes away.