I need to read the logs from the android application project through robotium test project. Please help me out.
Thanks
If you want to see the logs , Please use logcat, in Eclipse(that comes with android SDK).
Go To:
Window --> Show View --> other --> search LogCat
In LogCat you can see the logs for both Application under test and your test project. To use android's inbuilt logging library , you can do something like Log.d ("I am a Log");
In LogCat you can filter your preferred logs by creating a filter by clicking on the + button there.
If you want to wait for some log to appear or assert some log messages use the following methods:
solo.waitForLogMessage(String logMessage, int timeout);
Related
In my android project I'm using Crashlytics to get the app crash reports.I have also added the logs to see it in my dashboard.For adding logs I've used
Crashlytics.log (Log.ERROR, TAG, message);
So when I run the app for testing,and open the activity where I've added the Crashlytics log statements ,the logs were generated for the first time .I can see them on the dashboard. But when I again open the same activity ,I'm not able to see the new logs generated . I read here that if the logs are not seen on the dashboard then restart the app.I did that ,but still couldn't see the logs on the dashboard,my dashboard only shows the logs which were generated for the first time.I also tried testing my app on different device but it still doesn't show on the dashboard.Can somebody please help me in solving this issue .Why am I not able to see all non-fatal logs on my dashboard?
IF this doesn't produce errors you have to wait for logs registered on your dashboard in free account
Mike from Firebase here.
Crashlytics.log (Log.ERROR, TAG, message); will only be displayed if there is also a non-fatal - Crashlytics.logException(e); or fatal exception. We prioritize capturing exceptions (fatal or non-fatal) over logs so if you log the value immediately before the exception, depending on the size of the log, it may not be recorded. This is because we think capturing the exception is more important than the log.
I am new to Android. Please help me to know about the best practice of using Android Logger. Do I need to keep a file somewhere in android and keep on writing logs into it, or writing of logs into file is not necessary. What could be the best practice.
My real intention is this.
Once we go live, if our customers come back and tell us that something crashed or does not work in their android , then how do we debug ?
In the web application, I would ask my server administrator to provide the log files. What do we do with the android application when there is no server error, but something failed in the phone. Is there a way to get logs from the phone.
Thanks
Ravi
Depends on what you need, you need logging for semi debugging your application than you can easily use the buildin Log functionality. Via Logcat you can easiliy see the logs.
http://www.vogella.com/tutorials/AndroidLogging/article.html
//Declare a tag
String TAG= "SomeActivity";
//Log
Log.d(TAG, "Hello World"); //debug
Log.e(TAG, "Hello World"); //error
If you want to have logging of multiple devices when you have released your app. Use a dedicated Log Framework (e.g. Log4J) and upload it to a server.
One tip (if you are using Eclipse, and not directly related to question) - Eclipse is very unreliable for viewing logs. For apparently no reason it completely stops displaying logs every now and then. A simple solution is to use command line tools for viewing logs. On Linux you can do :
$adb logcat MyTag:D *:S
If you want to capture logs to a file you can do:
$adb logcat -d > logcat.txt.
Hope this helps!
If you are planning to publish/distribute your application then storing logs in a file is possible but as per my opinion better not a better solution. You can configure online tools from your app.
Catch all sever exceptions and sending all the details regarding that exception. And configure any one logging tool into you application.
You can see log4j http://logging.apache.org/log4j/2.x/ or ACRA http://acra.ch/ or http://www.crittercism.com/
The Android logger's (android.util.Log) output goes to a console that you don't have to maintain. You don't actually have to manage files, just outputs.
You have 5 categories of log:
verbose: use Log.v(tag, message)
debug: use Log.d(tag, message)
info: use Log.i(tag, message)
warning: use Log.w(tag, message)
error: use Log.e(tag, message)
For example:
Log.e("MyActivity", "Oops... caught this exception: " + exception.getMessage());
The LogCat console (this is its name) allows you filtering by log level. This is a ceil filtering. For example, if you filter by 'warnings', you will see all warnings and errors, but not verbose, debug and info messages.
You'll find more details here in the official documentation.
My real intention is this.
Once we go live, if our customers come back and tell us that something crashed or does not work in their android , then how do we debug ?
In the web application, I would ask my server administrator to provide the log files. What do we do with the android application when there is no server error, but something failed in the phone. Is there a way to get logs from the phone.
If you use file for storage logs - it possible problem with performance if the file become big. So you need clean file in time.
As for me best solution use firebase or https://fabric.io/.
We use fabric.io.
Also you can use some wrapper for default Log class. This one https://github.com/JakeWharton/hugo for example
I'm following documentation as states:
https://developers.facebook.com/docs/ads-for-apps/mobile-app-ads/#advanced
Specifically: Measure App Installs
However, I did the following code:
com.facebook.AppEventsLogger.activateApp( this, APPLICATION_ID_FACEBOOK );
However, in dashboard, it doesn't detect the install:
Any tips?
LogCat outputs the following:
FacebookException: No attribution id returned from the Facebook application
Ok. Solved.
Basically for whoever faces this:
FACEBOOK APP must be installed in device.
USER must be logged in.
Thats it.
=)
Another great but hidden hint is to enable verbose logging via
FacebookSdk.addLoggingBehavior(APP_EVENTS)
The output is actually very helpful and even contains error analysis and descriptions.
I am using Titanium Studio for my first Android App. In the documentation I've come across Ti.API.info() to print any debug message. But I am not able to figure out where exactly does it print. Please help me.
Ti.API.info() prints to the console. So, I have a function like this:
function OnAppResume()
{
Ti.API.info('***---> OnAppResume');
}
$.window.addEventListener("open", function() {
var activity = $.window.activity;
activity.addEventListener('resume', OnAppResume);
});
I run it. I'll get this response in the console.
[INFO][TiAPI ( 702)] ***---> OnAppResume
BTW, $. is the new convention for Alloy MVC. Don't let it throw you off. Hope that helps.
I personally use the DDMS console log in Eclipse. Ti.API.info() doesn't work for Android in Titanium Studio however it does log to the console. See attached image.
Ti.API.info() prints whatever inside the brackets in the console.
for example :
btnSubscribePush.addEventListener('click', function(){
Ti.API.info('subscribed to push notification');//Printing your message to console
wndSubscribe.close();//Closing the window
Ti.API.info('Your message printing here');//Printing your message to console
});
You just check the console window, the message will be printed in the console as shown in the figure
I'm trying to play with debug in Android app and, when a breakpoint is encountered, Eclipse shows me a lot of windows, one of which is the "Interactive Console" with a prompt: I think to be able to enter statements and/or other stuff, but it seems to be disabled.
How can I work with it?
Window - Show View - Debug - Display
That will provide you with a window to enter statements and execute/inspect them.
This is a feature that's available in core eclipse platform. It works in most cases for Android based projects as well.
More info on the display view can be found here : http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.jdt.doc.user/reference/views/debug/ref-debug_view.htm
For a nice overview of the debugging features of Eclipse, check out this post : http://www.cavdar.net/2008/09/13/5-tips-for-debugging-java-code-in-eclipse/
The "Interactive Console" within the Debug View of Eclipse is used whenever the debugged program expects some input from the console.
It's possible you have other plugins installed that provide that view, and it's not meant to be used by Android Java code. See here (not accepted answer, but community-favored one).
You can use Logcat for and can see your check points using
android.util.Log.e("","CheckPoint");
You can toast your check points using Toast like:
Toast.makeText(this, "Write here what you want see",1 or 0).show();
1-> long time displaying and 0 for short time.
This toast display in your device screen when programe running.
You can use console screen for seeing output like print statements Ex---
java.lang.System.out.print("Checking");
use
try{
statements...;
}
catch(Exception e){
System.out.println("the error message "+e);
}
will show the error messages.