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.
Related
When I try to build my project, I get the following error:
In the end it is stated: "check logs for details". Where to find those aapt2 logs?
NOTE: regarding disabling AAPT2, it's not a good idea. AAPT is now deprecated and will be removed by the end of 2018. Disabling it just delays the problems you'll have to fix either way when AAPT is deprecated and removed.
The logs do unfortunately not show up directly in the regular build window. I'm not sure why, or who thought it was a good idea, but that's how it currently works. You'll need to pop into the text-based version.
Using AS 3.1 (possibly 3.0 as well, I'm using 3.1 so I can't test there) or IntelliJ 2018.1, you open the build tab:
In this case I intentionally created a syntax error in some XML code (there are other places you can get AAPT2 errors too, like in the manifest or Kotlin, or somewhere else. This is just for the sake of demonstrating). I've highlighted a button in the image. If you hover over the button it should say "Switch view". Click it and you'll enter the text-based version of the build tab:
In this case I set an XML property to a non-existent value. The actual problem is formatted as JSON (see the content of the red circle). Inside the pink one is the actual error message (resource not found), the blue circle contains the file (in this case label_layout.xml) and content of the black circle contains the location (line 4).
What the actual error is will vary from time to time, so I'm not going to add how to solve it, because there's a wide range of different problems that could be the cause. Most of the time it's your code (so far I haven't seen any cases where AAPT2 crashes or has a bug that prevents compiling). Actually solving these issues get a lot easier with decent log output.
For reference, the same applies to compilation errors:
Though the syntax is slightly different:
The icon changed in a later version. I will not be keeping active updates of the icon itself beyond this.
For future reference: hover over the buttons in the build window until you find one that says "Toggle view":
That is the button you're looking for, regardless of what icon Google decides to use for it in future versions of Android Studio - at least until they fix the issues.
After making a series of edits to a previously working android project in eclipse, I attempted to run the app and got a message "Your project contains errors, please fix them before running your application." Normally under these circumstances there are either some red marks next to the offending file(s), and/or text descriptions of errors listed in eclipse's "Problems" tab. But this time there are no red marks to be seen anywhere, and the errors I see described in the "problems" tab refer to files that (as far as I can tell) have nothing to do with my project.
I noticed that at the top of my list of problems it says "Errors (100 of 192 items)... I am wondering if perhaps I am being shown 100 problems from other projects (I have many on the go at the same time) and my critical error is one of the 92 remaining which I'm not being shown... I'm stuck as to how to proceed.
Close the projects you don't care about and do a clean build.
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'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.
I'm just getting started with eclipse and android development. One thing which is driving me crazy in eclipse is the problems panel with error/warning messages. It displays errors and warning from every project that I have added to eclipse. I only want to see feedback from the project (or ideally individual file) that I am currently working on).
For example, I have two android projects added to my eclipse workspace: HelloAndroid (a sample app) and SMSTest (an SMS2Toast example). Even with no files open, I see warning messages from both projects! Why is this!?! I shouldn't see any output unless I actually have a file open...or is this just the way eclipse works? Should I be using a different workspace for each project?
Thanks for any help anyone can give me.
This will get mostly what you want:
Open the "Problems" view (Shift-Alt-X-Q)
In the right hand corner there is a drop down arrow
Select "Configure contents"
Then pay attention to the "Scope" options
I also highly recommend in that same menu "Group by" -> Java problem type.
Right-click the unwanted projects and click "Close Project" you shouldn't get notifications from them at that point.
Other than that I'd recommend fixing most errors before moving away from them. If you're not prepared to complete various functions at any given time just put a stub in them that satisfies conditions with a quick //TODO: statement telling you to fix it later.
If you're talking about working on a page in general and the errors are combersome and annoying then try double-clicking on the tab for the file you're coding (above the code window) and it should become "fullscreen" hiding the other portions of eclipse.
As far as I know, this is the way eclipse works. It makes sense in that if you make a change in one file, and it causes a compilation error in another file that you don't have open you would still want to know about it.
You CAN configure which situations are considered WARN, and which are IGNORE in Preferences > Java > Compiler > Errors/Warnings.
Also, if you only want warnings from one project you can CLOSE the other project, which would keep you from having to reconfigure a new workspace for each.