Question

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

Was it helpful?

Solution

I usually use the warnings to clean up my code in the following manner:

  1. They tell us which variables are never used locally. Hence, DELETE them.
  2. Use of deprecated stuff in android, hence keeping my code up-to-date.
  3. Removing unused imports.
  4. Useless assignments to variables.
  5. 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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top