Strange Lint-errors in Android project - android

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.

Related

Android Studio Inspections doesn't work correctly

When I run inspect on my code it shows a warning like this:
Property "isLoading" is never used
Even though I am using that property. There are no problems with code, everything works fine, but this issue annoys me, what should I do?
You can see both warning and usage of that property in the photo below:
If the answer above doesn't work,
Go to your local drive -- Users -- Android Studio -- System
and delete the caches folder, then open android studio.
Go to file -> Invalidate Cache/Restart
Click on Invalidate Cache/Restart, a menu pops up
On the menu, click on Invalidate Cache and Restart
// Wait for android studio to restart.
I made an enormous mistake. I assumed Android Studio knew what it was doing when it said it found unused resources and I let it remove them all. It removed much needed XML id tags, it removed drawables, launcher icons.... what a mess. Has no one in Android studio land addressed this egregious set of errors? I spent a far too much time undoing all the things "Inspect code" said was wrong and I let fix only to find the app fails.
Lesson learned - never assume Android Studio knows what it is doing when it comes to inspections. Always check each before taking their often erroneous suggestion

Android Studio shows symbols in red but it compiles OK

The wise ones suggest dramatic solutions. Is there any harm happening? can I hope that it will recover all by itself. Is this a "cloud no bigger than a man's hand" coming to engulf my project in a terrible storm?
There are 3 cases that i can think about :
1)You have got some kind or warning for example :
Lets say that you are using google maps and want to add "current location button" - if you wont check if the user accepted location permission or not you will be able to run your app but you will have a warning in red line.
2)If some view is marked in red but everything compile with no errors , this is some error and cleaning and rebuilding your project should fix this
3)If some file name is marked as red , there may be some error/warning inside that file itself(for example - XML error inside some layout that allow yo to compile your app)
#user462990 If you can't see any obvious issues. I'd suggest the static analyzer Lint tool. It inspects your code and would give you a detailed report of all issues wrong with your project.
Just go to Analyze->Inspect Code.
In the Specify Inspection Scope dialog that appears select Whole project.
Lint inspects your code without building it and gives you a report of all the issues in the Inspection Result tool window at the bottom.
Clicking on any of those issues takes you to the editor at the exact line of code where the issue occurred.
See below captain Lint reporting for duty 💪.
What's the problem...
It's the color of the "R" now it's red, it was . always black before.
I compressed the project and re-opened it again and the viewPager which was red is now black.

Android Debugging wont work XSLT error

I ran my program just fine a few minutes ago, and when I added more functionality now it is telling me "The JRE Instance Default XSLT processor does not support debugging_ Would you like to debug using the default Xalan 2.7.1 processor instead?"
I did restart Eclipse maybe that has something to do with it? :/
It's my first times writing an app so if I have to set something in eclipse each time maybe that's why? and what is it if that is the case.
Thanks!
You were in an XML file when you hit debug, I would bet. Happens to me all the time. For some annoying reason it does something entirely different that I don't understand when you do that. Delete the .out.xml that should probably have been created, open a .java file, and try to debug again. Another way is to just right-click your project and do Run As > Android Application.

Android: Graphical Layout not working - doesn't show anything

My situation is: I once made an android project(2.2 version) but soon needed to format my computer. After formatting, I downloaded eclipse again but when I imported my project, I wasn't able to use the 'graphical layout' menu for xml. It doesn't show me anything like the picture below.
http://img525.imageshack.us/img525/3586/19978552.png
I cleaned the project and updated the Android SDK, however, none of these seemed to work well. What could be causing this?
Try restarting Eclipse. Usually that solves the problem for me when that happens.
Right click on your layout xml file and select Open With -> Android Layout Editor. It will force eclipse to open file in android's layout editor mode
None of above worked for me. what worked for me is:
1- Select a Google APIs Project Build Target rather than one of the Android X.X ones. This setting is in right click on project -> Properties->Android.
2- Make a change in XML and save it. Now switch back to "Graphical Layout" and it will show the layout.
For some, only 2nd step works.
This Question was asked 3 year ago, I am sure that you have get your solution, however i was also facing the same problem but got the solution in eclipse, here it is:-
1)Goto help->AboutEclipse->Installation details.
2)check the version of Android DDMS, Android development tool, Android hierarchy viewer, Android native development tool, Android trace view and tracer for openGl ES in installed software tab.
3)If they have different version than you have to update all of them.
4)Goto help->check for update in eclipse and follow the instruction.
5)Then restart eclipse.
This solve my problem.
The topic seems a little bit cold, but I wanted to add it nonetheless.
I had a similar problem with my layouts recently. When i create a project it automatically creates the layouts in the latest version of Android (eclipse shows it as version 22 of android as of today). But i can't see anything. So i just change the version to, say 18, and it shows ok. Furthermore if i want to change it back to version 22 it throws and exception, saying that a class can't be instantiated. (I am probably missing a class or a library on my system.)
Therefore if you cant see the layout it might be a good idea to switch back to earlier versions for development. cheers.

Blank Graphical Layout?

I don't get this. I've searched everywhere and no one's answers have solved this for me.
Why does this keep happening? I can't do anything! The XML Code is still there, but it doesn't show anything in the Graphical Editor. The Palette comes up if I change it to "4in WVGA (Nexus S)" or some other configuration, but I still can't see anything and the Theme drop down menu is unselectable. All my XML documents are like that.
Just delete any custom device screen configuration you have added . It will solve the issue :)
That just happen to me and after some attempts I found the reason.
When I first opened the project in eclipse I found some errors related with the version of Java. I changed the JDK compliance to 1.6 (Project->Properties->Java Compiler) and all errors dissapear but all graphical layouts went blank.
I uncheked "Enable project specific settings" (Project->Properties->Java Compiler) and now all the graphical layouts are working.
When everything fails, close eclipse and start it all over again, it solved my problem.
I also had that problem, it happened to me when i imported my project. after some time I came to reason just change the workspace of eclipse to folder, which contains your folder.
I changed workspace on opening eclipse, there can be some other way as well
hope this will solve it
If it has never worked for you (or something went wrong upgrading your SDK, as in my case), you may need to install an extra package. For me the issue was fixed when I installed Android Native Development Tools under NDK Plugins (SDK version 20).
I had this problem since I switched the option Show previews in the palette. I switched to show only icons, everything is ok now.

Categories

Resources