I need to remove all of Android Studios "This can be changed to" warning flags. I know I can reduce all the warning flags with the slider from inspections to Syntax.
I don't know if Syntax covers every non style warning, or if it also includes actual warnings. If it does, can you link me the documentation that says so? I need actual hard proof. I can't find much talking about the syntax warning highlighting.
I can ignore these, no problem but I'm seeing that my team is treating these like real warnings. When you take an existing code base and a team.. we waste a ton of times with hundres of personal style errors. I like to do if(boolean == false), Because it's CLEAR. A lot of these suggestions make the code, bleedin edge 1980s style, save every character efficient, but as readable as.. well.. 1980s code..
For example, we just spent half an hour trying to figure out if we had an error in an if statement, because it "could" have simplified it sorta.
Or my favorites where it tells you to change it, then tell you to change it back..
Also yes I know I can add suppressions, which cause errors in my coworkers Eclipse. . .
See if this helps, Preferences → Editor → Inspections,
Disable the those you don't want, eg. Pointless boolean expression under "Control flow issues"
reference: https://www.jetbrains.com/idea/help/disabling-and-enabling-inspections.html
You can also add this line above the pointless boolean you want to ignore. I use this a lot when using BuildConfig variables as they appear constant but are really not as they are controlled by the gradle build system.
//noinspection ConstantConditions,PointlessBooleanExpression
Related
I was working on a project in android studio and suddenly I found a man type logo
I hover my mouse on in for a second then it shows me
Current Inspection profile: Project default.
Click to configure highlightening for the file.
When i clicked on this button it shows me
Now I want to know what is the use of this option or is this is important or not?
It may can be stupid question but I asked this question just to increase my own knowledge becuse this option seems bit important
Thanks In advance!
Happy Coding!
This has little to do with code inspection, but one can only define what is being highlighted. One could call it the visual representation of the inspection results, as it clearly read "highlighting level". This option only is of use, when you have to work with an old crappy computer, but rather irrelevant on current hardware.
As the name suggest, it inspects your code for issues, errors, incompatibility etc. and may recommends better options. If your system is low on resources (RAM, Battery, CPU) you can select None and also you can choose the PowerSave mode.
I created an app which runs without any problem
But it contains lot of warnings
Here my question?
What problem will arise when app contains a warning
Thanks in advance
I usually use the warnings to clean up my code in the following manner:
They tell us which variables are never used locally. Hence, DELETE them.
Use of deprecated stuff in android, hence keeping my code up-to-date.
Removing unused imports.
Useless assignments to variables.
Errors in Manifest like not setting "allowBackup=true/false"
etc etc...
No errors, but only warnings, means your code will run well. But the code may not be the best.
The difference in an error and a warning is that an error doesn't allow the code to be compiled. A warning on the other hand is a message from the compiler telling that you have something weird or unnatural in your code, but it's still able to compile.
A warning should be interpreted as "this is weird, but if you know what you're doing, then it's OK".
For example, pointer casting (from one object type to another object type) is a common source of warnings, but if you know what you're doing and you're confident it will not fail, you can ignore it.
Warnings are not errors, and as others have said, if you know what you are doing you can ignore them. But remember that warnings are the compiler trying to help you, and programming can be difficult enough that you should be grateful for any help you can get. A good way can be to ignore only those warnings that you know exactly what they are caused by, and be very suspicious of any others. And always try to get rid of all the warnings, so the important ones don't get lost among all the unimportant ones.
Warnings are only indicators that there's something wrong, but this something isn't critical for running your app. Sometimes it's just that an imported code isn't used at all, another time it's a hint that a code can throw a NullPointer that you aren't catching right now. But summing up, warnings are not critical - at least during development time.
So far, you should only care about the errors that will prevent you from compiling your app.
It depends upon the types of warnings you have. If you have Deprecated Warnings then
You can configure the Java Compiler to ignore the Deprecated Warnings. I'd suggest to configure this setting for the specific project, not globally. To do so, right-click on your project and go to Properties > Java Compiler > Errors/Warnings. Click Enable project specific settings and then unfold Deprecated and restricted API and select Ignore for Deprecated API.
This will disable all deprecated warnings though.
since I updated my Android SDK today I get some strange Lint errors in my project. The activity contains amongst others a textview. Everything works fine, but if I want to change the text size of the view within the code with .setTextSize(float size), I get in other lines (and also other independent methods) errors that a call requires a certain API level. But that are calls like string.isEmpty(), which is available since API level 1.
What am I missing? And I know, I can set the text size also in the xml-file, but I want to change it during runtime.
Any ideas?
Thanks!
Best regards
Tobi
I think I got into something similar some time ago (nonsense Lint errors)...
Are you working with Eclipse?
If so, you can try the following:
Restart Eclipse
Clean your project (Project->clean...)
Click the button "Runs Android Lint..." (it's in the toolbar, between the "Virtual device manager" and the "new project wizard")
I don't remember exactly what did I do to solve the problem, I hope it works though
Good luck!
With the latest release, I've had a few times where the lint errors were just incorrect. (missing semicolon on a line with a semicolon, etc).
In such cases, you can right-click on lint error warning, or on the numberings on the left side, and select "Clear All Lint Markers".
This will allow you to compile the file once, and if that works, Lint seems to start acting normally again.
I understand there is the LogCat view to check the messages logged but I can't make sense of it.
When debugging (I use Java primarily) I've been accustomed to stepping over each line of code and finding out the exact point where the program crashes and then doing something about it.
How can I do this with Android development? Is there a way to precisely locate the line which is causing the application to crash?
I can't understand what to make of/how to read the LogCat messages and when I try to step over (using the F9 key or the 'Debug' option in Eclipse) it keeps opening new tabs for inbuilt classfiles (like Instrumentation.class etc) and after pressing F6 a few times over again the app crashes showing 'The application has stopped unexpectedly. Please try again'
Can someone tell me if there's something to be done in a way that I'm not doing here?
Thanks!
Btw if it helps, here's the generated log:
http://pastebin.com/EaqaWUdS
You are using a resource id that doesn't exist at line : 93 of com.site.custom.ModAdapter.getView(CustomListProjectActivity.java
--EDIT : add explanations
You will read a logcat stack trace in the same way as you did in Java : read bottom up and the culprit is the last line of your classes (before the code gets into the android sdk code).
You can do it the other way around, and start from top, stopping at the first class of yours and discarding android classes.
The same reasoning applies when debugging : step into your methods if needed and step over all methods of the SDK unless you want to debug them (and usually you don't, if you really suspect a bug inside the SDK, check the source at grepcode to see the inner mechanics of the android sdk class you are interested in).
Sometimes it gets difficult to track bugs on android, especially for widget layout related bugs because you can only see the code that is executed by the android platform, no code of your is executed, only your data are read from an xml file for instance. If something breaks here, it can be harder to debug. In that case, apply the dichotomy method : remove half line, if the bug doesn't show up, then readd your lines, remove half of them, etc...
It is the same like in java. Basically you need the sources to open the java files instead the class files. Google shows you how to add the sources.
Basically you debug android while staying in your own classes. I barely look into the android classes as the most issues are, of course, located in my own classes.
So just debug like you already do but don't step into methods/classes you don't own unless you have the sources added to your sdk. Even if you have, there might be some classes that aren't open source, so you can't step into the sources there. (Basically all Google API classes)
I'm using Eclipse for programming on Eclipse. Few days ago, I have installed many features of Enterprise Edition of Eclipse. When I program on Android and use Android Layout Editor again, I meet many strange thing:
1) I cannot reiceive error/warning. For example, when you use: android:text="stackoverflow", Eclipse will warnning: use should use String resource at Left panel (maybe x or !). But, I cannot see it now :(
#: hightlight as you see on StackOverFlow, but instead blue, it's red :D
2) Instead of warning/error, I will hightlight red at that line. for example: android:text="stackoverflow". And it's very difficult to me to follow.
I think maybe some config change, but when go to Windows\preference\android\Editor: I still cannot see any categories can fix it.
Please help me.
thanks :)
I'm not quite sure what you mean, but I'm assuming that you are no longer seeing warnings or error notifications in the XML editor. Check your settings at Window -> Preferences -> Android -> Lint Error Checking. Some error messages might have been set to Ignore. Any warnings or errors you want to see, you should set to either Error or Warning.
Take a look at Warnings in xml resources. This might point you in the right direction and give you visual cues.