Breakpoint in service not working - android

I am trying to add a breakpoint to a service running on a separate thread. No matter where I place the breakpoint in the service, they are always ignored.
I am sure that the service is running as I see the Log.e in the logcat. My debug mode is also correctly used as any breakpoint in the main thread of the app works.
Am I missing something? Is debug mode not supported for services in a separate thread?
I just updated Eclipse and Android SDK tools to the latest versions today.
I am testing my application on a device.

The android.os.Debug.waitForDebugger() did the trick. Add this before the line of code you want to debug.

Make sure that you declare the package name in the service tag in the manifest using android:process attribute, for example:
<service android:name=".YourCoolService"
android:process="your.package.here"/>

Related

Android app crashes without stacktrace on logcat

I run my app in Android Studio debugger and get "[AppName] keeps stopping", although it doesn't actually stop. It's just an android.app.Service that appears to be crashing, yet on LogCat I see no stack trace and putting breakpoints in the Service constructor, for example, it doesn't stop there either.
Android Services are running in their own processes. When you configure in your Manifest your service
<service
android:name=".service.SomethingService"
android:enabled="true"
android:exported="false"
android:process=":Something" />
Check logcat for :Something. You should find a process called yourappname:Something. There you find your stacktrace.
For the debugging part of the question you probably need to add this line:
android.os.Debug.waitForDebugger();
where appropriate in your Service' onCreate or so. Then you have time to connect to the process once the server is stuck on that line. Don't forget to remove the line before publishing.

Xamarin GCM Component - Manifest Malformed

I am developing an Android application with Xamarin.Android.
My application is running perfectly, but when I add GCM Component it gives the following error:
Android application is debugging.
The application could not be started. Ensure that the application has been installed to the target device and has a launchable activity (MainLauncher = true).
Additionally, check Build->Configuration Manager to ensure this project is set to Deploy for this configuration.
If I remove the component then it works fine.
Here is the image for the error:
I have tried many solutions from Google, but nothing has helped.
How can I prevent this error from happening?
You need to make sure that your package name does not start with an uppercase letter - from your screenshot, it looks like it does "RestaurantAPP".
This is a known issue with GCM itself and is not a bug in the Xamarin component: https://code.google.com/p/android/issues/detail?id=37658

Why are Log.d() messages showing on device when they shouldn't?

Android docs indicate:
The order in terms of verbosity, from least to most is ERROR, WARN, INFO, DEBUG, VERBOSE. Verbose should never be compiled into an application except during development. Debug logs are compiled in but stripped at runtime. Error, warning and info logs are always kept.
But try to do a Log.d() and you'll find it's actually still recording to Logcat on a real device.
Does anyone know why? Or how to disable it?
Thank you!
What you are seeing is expected behaviour. Log.d will always be logged and visible if you use logcat and connect the device. Hence if you dont want debug logs in production app , turn it off. Infact android sdk suggests you do that. This SO answer might help you as well. Should I comment my log calls when creating my final package?
Andriod sdk says
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.
Also, you should remove all Debug tracing calls that you added to your
code, such as startMethodTracing() and stopMethodTracing() method
calls.
Source
You should encapsulate logging in your own class and enable/disable special types of logs when you need.
if verbose is compiled in dvelopment, it would be funny if debug logs not. So signe your app and give it a try, i think the debug messages are missing then.
When you plug your device it activates the debug mode. I don't think it's doing the same if the app run with the device unplugged, though you can not check that...

Android Service application error - no launcher activity

I created a service application without any GUI...infact take help of other applications available on this website...but when i try to run it on my Emulator (2.3.3), I keep on getting error:
2012-02-13 17:36:56 - RUN_SERVICE] No Launcher activity found!
[2012-02-13 17:36:56 - RUN_SERVICE] The launch will only sync the application package on the device!
After it installs properly, but i dont see my service running...i tried adding toast messages, but I am not receving that as well...i didnt try it on real device yet...as I didnt have any phone with this android version 2.3.3. I am using jre6
As your applicatinon does not have any GUI.
You must start the Service from at least one activivity that may be lanucher acitivity by using
<category android:name="android.intent.category.LAUNCHER>
So that your Service need to start when the app is installed or Run.
Make sure you have defined the activity in your AndroidManifest.xml file....
I think you mentioned this in your manifest <category android:name="android.intent.category.LAUNCHER>. if yes then remove this

Debugging not working in a service class ?? what can cause this issue?

All of a sudden I am not able to debug anything that i am doing in a service even though i put breakpoints all over. but logging shows that all the lines are getting executed. Can someone tell me what could be causing this issue. I am using eclipse and i have set to "Build automatically".
Do you have an Activity which is launched at the beginning of your application?
If not you have to manually activate the debug on your process by using the DDMS tool in Eclipse.
In DDMS -> Devices, check your process (the line contains the package name of your app), select it and then click on the debug button. A debug icon will appear near your process, then you should be able to use breakpoints in your Service.
If you are using a Runnable try placing this in the run() method:
android.os.Debug.waitForDebugger();

Categories

Resources