Modifying Android source code - android

I am absolutely new to Android. As a research curricular project, I want to make some changes in Android's activity manager's source code. I have downloaded the source code from here and built it for emulator. Now, to start with, I want to do some very simple things e.g. adding print statements to the module that I want to modify. This is just to make sure that my changes are actually showing effect. But how can I
See the changes I made. In this case, where can I see words/sentences printed by my print statements?
Even if I make such small change, do I need to build entire code base again using "make" command? Cant I just compile that particular class or file? I tried "mmm" and "mm" but they dont seem to be working. One says "nothing to build" even if I introduce syntax error and other says "no android.mk file found"
Can I add my own method to the ActivityManager class?
Thank you...

Related

Android Log - print link to line of code in c++ file

If you print in log (fileName:lineNumber) you get a nice link in Android Monitor that gets you to that code line when you click on it. This however does not seem to work for my cpp files. Is there a way to achieve this for c++ files?
Edit
I already know how to create string (fileName:lineNumber), but when it is printed in Android Monitor it is not a clickable link. The question is how to make clickable.
To appear as a clickable link in the Android studio Logcat window, (filename.cpp:filenumber) should be associated at least with one file that is part of your AS project:
You can see that some system logs are resolved to clickable links, while the others are not.
In the example above, Socket.java is part of public API, while PlaneSocketImpl.java is not, therefore AS does not show a link for the latter.

android app particular java file used

How can i know which java file is used at the current time at that current interface. I know we can do this with a logcat when we know the source code , we can make everything log.i and stuff. but what happens when we don't know the source code or while assessing a black box android app
If you don't have access to the files how you supposed to know which file you are getting?
The best way to achieve what you want is to use a decompiler in your APK and do a debug.
http://www.decompileandroid.com/

Customised settings no longer marking errors and problems

Until yesterday I had no problem with android studio and it's worked fine but today I have some problems with it .
For example, in my code I write " Strng s; ", as you can see I have wrong spelled the String, and android studio not tell me that this line is wrong.
or by default when you write code and use some libraries like Log or Dialog, android studio automatically import the necessary lib files but mine, it doesn't include them and also it does not mark it and tells me that I need to include the library.
so It make the coding very hard and full of problems .
How can I solve these problems?
Go File -> Settings
If you go into Code Completion, Auto Import and PostFix Completion along with setting your Code Style settings you have a lot of flexibility in what you choose the ide to show you.
In terms of you losing your settings, a file may have been deleted or over written, it's hard to say, it's something you learn to keep track of with your ides. Make a note of which folder your settings are saved to.

"Source not found" when debugging SOME classes of the Android platform code

I'm using Eclipse Kepler with the latest ADT, and I have already set the Java Source Attachment for android.jar to point to the correct directory.
With this setup, I can place breakpoints and step into most classes/methods with no problems at all. However, for some classes, Eclipse just refuses to load the source, and instead displays the standard Source not found screen, although the corresponding source file (ScrollBarDrawable.java) is present in the source directory (under android\widget).
The particular example I have now is with the android.widget.ScrollBarDrawable class, but it has happened with others before.
How to reproduce:
Create a simple project with an EditText in the layout.
Call editText.setHorizontallyScrolling(true); in onCreate() (so that it needs to draw scrollbars) and enter long text into it.
Place a breakpoint in the onDrawScrollBars() method of the View class, on any calls to methods of the scrollBar object (e.g. line 11967 for android-19).
Try to step into this method.
Has anyone else experienced this?
Any tips on how to fix it, or at least an explanation of why it might be happening (as in: this class is somewhat different from the others)? I have already trying added additional File System Directory entries to the Edit Source Lookup Path dialog, to no avail.

What does this Eclipse error mean about my Android app?

I am using Eclipse to write my Android app and I keep getting this error when running it. I have no idea what the error means or how to go about debugging.
I should add that this all started when I wrote a method to parse an XML file. Before I wrote that, the app worked fine. I tried adding some try/catch block that contain "log.e" statements, but I don't see anything strange in the log.
Does anyone have any idea?
The error message is in the screen shot below:
It means you don't have the source files of the Android code in you eclipse workspace. check
Android source
By default you only have the compiled class files in you android.jar. if you want to see the source(*.java files) you need to add them yourself. So, you have no source files at all by default
I have had this error come up before for a lot of reasons. Almost always it is because I tried to refer to a resource that either is not there, or is incorrectly formatted. Seeing as how this started when you worked with one of your XML files I would check there for incorrect formatting.
Although this error is referring to the fact that you do not have the full android source code, having it will not fix the error, it will only allow you to see where the source code is failing either to find or open your XML file.

Categories

Resources