Can someone give me an ide about method coverage in android apks without having the source code?
I heard that there is an android specific version of emma project that can give method coverage information through instrumentation. But if I do not have the source code how can I instrument th code?
My goal is to some how get a report on which methods were called in the runtime while running the application.
You don't need emma to get a report of which methods are called.
Just:
start DDMS
selected the device
select the process
press "Start method profiling" button (arrows with red button)
"Stop method profiling"
and you'll get a report like this one:
See the details at http://developer.android.com/tools/debugging/debugging-tracing.html
Related
I want to create a plugin for intellij idea and in that I want to get the inspections or code analysis errors.By default intellij will show those code inspections like errors, dead code, or unused components.So I want to get those inspections pro grammatically to my plugin.I am able to create an tool button from my plugin and getting the code. Process is,
created plugin for intellij Idea with some actions and tools
menu.
running the plugin, created separate instace in
intellijIdea
wrote some java code in new instance of intellij in editor
-->in that it will show
inspections or errors
so I want get those inspection to my plugin.How can I do that?
The simplest API for getting the inspection errors in a given set of files is CodeSmellDetector:
CodeSmellDetector.getInstance(project).findCodeSmells(files);
If you know what exact inspection you need, you can get it this way:
PhpUnusedAliasInspection inspection = new PhpUnusedAliasInspection();
InspectionManager manager = InspectionManager.getInstance(psiFile.getProject());
List<ProblemDescriptor> checked = inspection.processFile(psiFile, manager);
System.out.println("checked " + checked);
Outputs:
checked [Import 'Illuminate\Database\Eloquent\Model' is never used]
Where PhpUnusedAliasInspection may be any class that extends the LocalInspectionTool (you can list them all by opening the decompilled LocalInspectionTool class and clicking the Subclasses circle near the name).
I'm debugging a PaxExam integration test in Eclipse. I'm currently stepping through the code for a class and method that I don't yet have the source for. When it hits the breakpoint, it says "Source not found" (with the "Edit Source Lookup Path" button), but when I visit the class file I know it's using, it's able to decompile it (using jd-eclipse).
(Note that running paxexam tests actually forks a process, so debugging them requires setting the "-Xdebug" parameters in the run configuration of the test class, and then using a "Remote Java Application" configuration to connect to it.)
While stepping through most of the code, I can enter expressions in the Display view, even with available completions, and display values and execute methods.
When it hits the breakpoint in the decompiled class (showing "Source not found" in the editor view), I can see the local and instance variables in the Variables pane. I can then switch to the view of the decompiled class and use the stack trace info to see what line I'm on.
At this point, if I try to enter any expression in the Display View and display it (even just "this"), it says:
Evaluation failed...To perform an evaluation, an expression must be
compiled in the context of a Java project's build path. The current
execution context is not associated with a Java project in the
workspace.
I'm trying to get access to the source code for this class, but I would think I wouldn't need to go to that point. Is there a reasonable workaround for this situation?
I'm trying to migrate from Eclipse to Android Studio. There are a few things that bug me, but one stands out:
Q1: Is there no way to do automatic builds and have a list of problems displayed immediately like in Eclipse?
I know, there are many refactoring tools, but my often-used practise is to just insert a character into the name of a method and variable and check problems-view to see where it's being used.
Q2: How can replace or replicate this workflow in Android Studio?
One thing you can do is deactivate the external build. To do so click on "compiler settings icon" in the "Messages Make" panel that appears when you have an error. You can also open the compiler settings by going to File -> Settings -> Compiler. (Thanx to #maxgalbu for this tip).
enter image description here
Uncheck "Use External build"
enter image description here
And you will see the errors in the console
EDIT: After returning to "internal build" again you may get some errors, you can solve them this way: Android Studio: disabling "External build" to display error output create duplicate class errors
I'm following the instructions in this blog post (http://www.badlogicgames.com/wordpress/?p=3073) for trying to debug the GWT version of my LibGDX project.
I can compile the GWT project fine, and start the superdev code server using en Eclipse "Run As" profile. I then start Jetty using mvn verify -Phtml, browse to localhost:8080/index.html and enable dev mode as per the blog post. Something of note is that I don't see the dialog box as described in the post ("GWT modile 'blah' may need to be recompiled").
When looking at sources in Chrome's developer tools, I don't see any of my linked Java source under the localhost:9876 tree node; instead I see something like this:
localhost:9876
projectname
gwt/chrome
chrome.css
{some long MD5-lookign thing}.cache.js
projectname.nocache.js
It's be ace if I could figure out how to see my code linked there and put breakpoints in, as at the moment I'm getting a GdxRuntimeException with a message of "Not implemented" thrown somewhere, but I've no idea from where.
I just started using Eclipse so go easy on me ;). But when trying to debug a JUnit test case I get a dialog that states the the source is not found when I get to this line in the code in my test method:
Assert.assertEquals(1, contents.size());
I know I should probably go and try and download the source from somewhere, but I really don't want to because I have no interest in stepping into the JUnit code. I have the JUnit runtime jar so Why does Eclipse expect me to have all the referenced tools source code in order to debug my own code (seems somewhat silly)?
My main question is though, how can I tell Eclipse to skip this dialog when the source is not available and allow me to continue to debug my own code?
[Edit]
I've isolated the cause of this. It seems that Eclipse seems to think it needs the source when an exception is thrown by the internal JUnit code. In general is there anyway to tell it that it doesn't and just have it throw up an error dialog of some kind instead?
I had this very annoying problem for a long time but was finally able to solve it. In my case, a null pointer exception was being thrown somewhere in Java's Transformer.IsRuntimeCode(ProtectionDomain) function.
I didn't really need to know about this since the exception was being caught and handled, but eclipse would pause debugging every time this happened and tell me that the source wasn't available. As a result, I constantly had to keep pressing the button to continue code execution.
In order to prevent this from happening, I:
Clicked on the "Breakpoints" window
at the bottom of the debugging
screen
Right clicked "NullPointerException"
Unchecked "Caught"
This prevented the debugger from pausing program flow during a caught NullPointerException.
(source: SharpDetail.com)
The debug callstack will display a JUnit source code line when throwing an exception.
But you should not need to worry about that, if you do not have the source code of JUnit.
If you go back one line in the callstack, you should see the line (of your source code) which has caused the JUnit exception.
That should be enough to debug your code.
To associate the source with JUnit, you could add the junit.jar in the librairies of your project, and associates the junit-x.y.z-src.jar to the junit-x.y.z.jar, like so:
That will generate in the .classpath of your project a line like:
<classpathentry kind="lib" path="junit-x.y.z.jar" sourcepath="junit-x.y.z-src.jar">
Note: actually, there would be the full path of the junit[...].jar files in this classpathentry line. But you could also use Linked resources to avoid that fixed value (the full path) in your .classpath file.
I had a similar problem. I fixed it by right clicking on the project folder in the package explorer and selecting refresh. The code source was out of sync with the debugger and this corrected it. The Transformer.IsRuntimeCode(ProtectionDomain) Source not found message no longer appears.
Calculate contents.size() on a separate line instead or set a breakpoint on the method.
Also note the junit view in Eclipse allows you to navigate the stack trace.
Use the Step Filter to avoid stepping through the ...junit... packages. Right click on the stack trace and choose Filter Package. You may have to turn on filtering first with Use Step Filters. ~~~
I had a similar problem with another jar, even when I pointed to the source it would ask for it again. I was able to solve it by compiling the jar with debug="on" on ANT.