I marked a few break points and launched the debugger, but after the application is installed, the break points don't get the "v" sign, and the debugger doesn't seem to stop when reaching to them! I really don't know what I'm missing here. Could it be related to the fact that it's an app widget application? I didn't have this issue with other applications...
I'm using the emulator, if it matters somehow.
Thanks.
Is your application set to false for debuggable in your manifest? It shouldn't be in there at all or set to true.
<application android:debuggable="true" >
Also try to use this in the onEnabled():
android.os.Debug.waitForDebugger();
Another way could be by using the DDMS perspective and selecting the widget from the list of processes.
This link might be helpful as well.
Check that you do not have "Skip all breakpoints" set in Eclipse. Run -> Skip All Breakpoints. If that is set, Eclipse allows you to set breakpoints, but does not stop at them.
Related
I'm doing some reverse engineering protection on Android and I want to prevent debugging of the app. I know how to detect when a debugger is attached but is there a way to block it from attaching in first place?
Edit: For clarification and in response to droidpl's answer, I mean ways beyond just setting debuggable=false in the manifest in case the .apk is repacked.
Yes, you can modify your build process to make your app not debuggable. In the build.gradle of your app, in the build type you want to avoid it to be debuggable, set the property debuggable false.
Now if you try to attach the debugger to your process, it won't appear in the running available processes.
My question is, when we use Log.d(), Log.v(). Are these visible on android screen as output or do they just remain in the background and Android Mobile just display what the emulator displays in Computer?
Logging is just something, that enables developers the possibility to check if his code is working like it's intended to be, the user won't see any of the log statements. But it's recommended to remove all logs before publishing your App:
Turn off logging and debugging
Make sure you deactivate logging and disable the debugging option
before you build your application for release. You can deactivate
logging by removing calls to Log methods in your source files. You can
disable debugging by removing the android:debuggable attribute from
the tag in your manifest file, or by setting the
android:debuggable attribute to false in your manifest file. Also,
remove any log files or static test files that were created in your
project.
Source here.
No, this is purely a background thing, viewable with the LogCat view in Eclipse. The user will not see anything Log related, they will be oblivious to it while using the app.
So yes, it will display what your emulator displays. Of course if you need them to see something, you can show Toasts and Dialogs. However, make sure to take out Log statements in release versions of your app. People that have debugging enabled will be able to see your statements if they attach their phone to a computer and run LogCat.
any best way to debug exception unless using logcat since the overall code are very big? do u think using break point to view the value if installing apk into actual android phone and running it on the phone via usb cable?
do u think using break point to view the value if installing apk into actual android phone
If this means, 'can you debug using breakpoints on the actual phone?'. The answer is Yes
Here is a tutorial you can follow
The size of the codebase is mostly irrelevant when trying to find the cause of an exception (It might complicate things a little, but in general the procedure is the same as debugging a small application). Debugging is the most efficient way of finding bugs, because you're running directly inside your application and you will not have to speculate about the current state of your application (you can actually look at it).
I suggest that you...
Get familiar with Eclipse debugging
Read the stacktrace
Try to find the exact line in the code where the exception happened (according to the stacktrace)
Set a breakpoint at the exact line or at the beginning of the method
Restart you application and wait until you hit the breakpoint
Inspect the variables using the tools in Eclipse
Hope that helps.
Please note, unlike many other questions having the subject title "application has stopped unexpectedly", I am not asking for troubleshooting a particular problem.
Rather, I am asking for an outline of the best strategy for an Android/Eclipse/Java rookie to tackle this formidable task of digesting huge amounts of information in order to develop (and debug!) a simple Android application.
In my case, I took the sample skeleton app from the SDK, modified it slightly and what did I get the moment I try to run it?
The application
(process.com.example.android.skeletonapp)
has stopped unexpectedly. Please try
again.
OK, so I know that I have to look LogCat. It's full of timestamped lines staring at me... What do I do now? What do I need to look for?
Is there a way to single-step the program, to find the statement that makes the app crash? (I thought Java programs never crash, but apparently I was mistaken)
How do I place a breakpoint?
Can you recommend an Android debug tutorial online, other than this one?
I'm an Eclipse/Android beginner as well, but hopefully my simple debugging process can help...
You set breakpoints in Eclipse by right-clicking next to the line you want to break at and selecting "Toggle Breakpoint". From there you'll want to select "Debug" rather than the standard "Run", which will allow you to step through and so on. Use the filters provided by LogCat (referenced in your tutorial) so you can target the messages you want rather than wading through all the output. That will (hopefully) go a long way in helping you make sense of your errors.
As for other good tutorials, I was searching around for a few myself, but didn't manage to find any gems yet.
Filter your log to just Error and look for FATAL EXCEPTION
If you use the Logcat display inside the 'debug' perspective in Eclipse the lines are colour-coded. It's pretty easy to find what made your app crash because it's usually in red.
The Java (or Dalvik) virtual machine should never crash, but if your program throws an exception and does not catch it the VM will terminate your program, which is the 'crash' you are seeing.
Check whether your app has the needed permissions.I was also getting the same error and I checked the logcat debug log which showed this:
04-15 13:38:25.387: E/AndroidRuntime(694): java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:555-555-5555 cmp=com.android.phone/.OutgoingCallBroadcaster } from ProcessRecord{44068640 694:rahulserver.test/10055} (pid=694, uid=10055) requires android.permission.CALL_PHONE
I then gave the needed permission in my android-manifest which worked for me.
From the Home screen, press the Menu key.
List item
Touch Settings.
Touch Applications.
Touch Manage Applications.
Touch All.
Select the application that is having issues.
Touch Clear data and Clear cache if they are available. This resets the app as if it was new, and may delete personal data stored in the app.
When I run my app on my phone from eclipse, it always runs in debug. This has only recently started to happen. I guess I must have inadvertently changed a preference or something, but can't work out what. Does anyone know how I can switch it back so I can run without debugging?
Thanks in advance
TAO
I found someone else reporting the same error
http://osdir.com/ml/AndroidDevelopers/2009-08/msg00603.html
They resolved it with a phone restart.
The same worked for me.... how frustrating!!!!!!
At least its working now.
Massive thanks Aaron Digulla for our help.
TAO
Check the VM options in the project's properties. There should be something like -Xdebug=.... Remove that.
I suggest to duplicate the entry and create a second one without the debug options. Also note that under Common, you can save the launch config somewhere (for example in your project), so this setup doesn't get lost.
Just ran across this issue.
Sometimes the Eclipse Android dev environment sets the application property android:debuggable="true" in the AndroidManifest.xml file. This will cause your app to run in debug mode regardless of if you press 'run' or 'debug' in Eclipse.
I know this contribution comes a little late, but here it goes. Be sure you do not have any android.os.Debug.waitForDebugger() method invoked since your code. If so, just remove or comment it and rerun your application.