LogCat Android - how to get filename with the error - android

I have this problem:
I start a java application as "Android application" in Eclipse Juno.
So the virtual device starts and the log messages begin to scroll in the LogCat tab.
The columns of the tab are Level, Time, PID, TID, Application, Tag, Text.
Is there a way to see the filename where an error message comes from ?
For example I get the text: "sqlite returned: error code 14, msg=cannot open file at source line 25467" and the tag is "Database".
So how could I know in which file this error has been generated ?
Thanx
A

You can double click in the red lines and they jump to the code source which gives the error

You can use filename as a tag while logging. E.g Log.i("YourFileName", "Your Log");

Somewhere it usually says "caused by" and then it lists files and lines where the exception happened

I systematically add a
static final String TAG = "ClassName";
property to all classes definitions and use it on
Log.x(TAG, "Whatever");

Related

System.out.print with // prints the code Blue. What is the meaning of this?

System.out.println(TAG + " //METHOD_STARTED// - //start_firebase_and_get_userID//");
Why if I write these in my app, it comes in blue in the console after the //?
It appears to be mistaking it for a hyperlink.
//METHOD_STARTED// is a valid protocol-relative URL (domain names don't have to have dots if they're on your local network), and it seems that Android Studio/IntelliJ's link detection is falling for it. Of course, it's not valid in this case, because there's no protocol in the log output for it to be relative to, so really this is a bug.

What is the purpose of using double underscore ( __ ) before the start and after the end of an file name in c?

I'm studying the android kernel as a beginner. I can read the messages thrown from the macro ERROR() inside the function main() at system/core/init/init.c using dmesg command through adb. I observed that after calling the function open_devnull_stdio() inside main(), dmesg no longer displays the messages thrown by ERROR().
To find the reason, I started digging into the declaration of open_devnull_stdio() inside system/core/init/util.c and I found this line I can't understand
static const char *name = "/dev/__null__";
Actually there was no file named __null__ inside /dev/ in the device, but there was a file named null and I was able to grab it using adb pull and it was a 0 byte (empty) file.
So why is a file name wrapped with double underscore (__) ?
Here is the link for the util.c
There is no special purpose of using double underscore before the start, after the end or both in C. From the point of view of C the file name is just a string, the operating system is free to interpret in whatever way it chooses. From the point of view of Linux, the same applies. Underscores in file names are just characters. They are not treated differently from the letters b and t.
If I guessed right and I'm reading the same file as you (it might be a good idea to link to the source code you're reading) then it should be pretty obvious what the code does on the lines after the one you mentioned. The next lines are:
if (mknod(name, S_IFCHR | 0600, (1 << 8) | 3) == 0) {
fd = open(name, O_RDWR);
unlink(name);
Which creates the null device which is then opened and immediately deleted again.
I suspect this is done so that programs can run without access to the root filesystem and still be able to open the equivalent of /dev/null.
I don't know the answer but I have an idea:
The following page shows an "strace" output where /dev/__null__ is used:
https://gist.github.com/tetsu-koba/1522515
Under Linux device files have a 33-bit (?) number which identifies the device. (At least under old Linux versions) you could delete some file in /dev and you could restore it or even create it in another directory (!) when you know the 33-bit number! (So you can delete the device /dev/sda2 and create the device (not file!) /home/myuser/sda2 instead.)
The trace in the link above shows the following three lines:
mknod("/dev/__null__", S_IFCHR|0600, makedev(1, 3)) = 0
open("/dev/__null__", O_RDWR|O_LARGEFILE) = 3
unlink("/dev/__null__") = 0
These lines will create the device file /dev/__null__ (with the 33-bit number identifying /dev/null). Then it opens that file and then it removes the file again.
Maybe this is done because the tool shall be able to run both on Linux installations where the device file "/dev/null" is present (in this case the file should not be overwritten) and on installations where that file is missing (in this case a replacement file must be created using the known 33-bit number).
As other people have pointed out this just tells it's the "null device", not a regular file called "null". null is supposed to act like an information sink, not like a normal file where you dump your data to. Hope this helps.

C++ Builder WSDL client for Android

I'm having a confusing problem. I'm trying to make a Web cleint that uses WSDL.
I'm using C++ RAD Studio 10 Seattle, but the same problem occured in RAD Studio XE8(older version).
1.I create a Multi-Device Application, add one Edit component and one Button.
2.I create a WSDL Importer by changing the location of the WSDL file to : "http://www.w3schools.com/webservices/tempconvert.asmx?WSDL" and leave all other setting to default.
3.On ButtonClick event of the button I write two lines of code :
_di_TempConvertSoap Converter = GetTempConvertSoap(true,
"http://www.w3schools.com/webservices/tempconvert.asmx?WSDL");
Edit1->Text = Converter->CelsiusToFahrenheit("32");
So after these three steps I have one unit, which is the main Unit with the Form and with the button event. And one file "tempconvert.cpp" that the WSDL Importer has generated. It quite actually just translates the WSDL code to a C++ one and defines the method to communicate with the server. In my case I have two methods : FahrenheitToCelsius() and CelsiusToFahrenheit(), in the example I use CelsiusToFahrenheit().
I compile it to 32-bit Windows platform, run it and when I click the button, the result "89.6" appears in the text of the Edit component. So this is working as expected.
But when I change the target platform to "Android" and use my mobile phone "Samsung GT-I8262" with Android 4.1.2 and run the project, it just stops and exits. I debugged the problem and it stops at the first command in "tempconvert.cpp" in RegTypes() method.
// ************************************************************************
//
// This routine registers the interfaces and types exposed by the WebService.
// ************************************************************************ //
static void RegTypes()
{
/* TempConvertSoap */
InvRegistry()->RegisterInterface(__delphirtti(TempConvertSoap), L"http://www.w3schools.com/webservices/", L"utf-8");
InvRegistry()->RegisterDefaultSOAPAction(__delphirtti(TempConvertSoap), L"http://www.w3schools.com/webservices/%operationName%");
InvRegistry()->RegisterInvokeOptions(__delphirtti(TempConvertSoap), ioDocument);
/* TempConvertSoap.FahrenheitToCelsius */
InvRegistry()->RegisterMethodInfo(__delphirtti(TempConvertSoap), "FahrenheitToCelsius", "",
"[ReturnName='FahrenheitToCelsiusResult']", IS_OPTN);
/* TempConvertSoap.CelsiusToFahrenheit */
InvRegistry()->RegisterMethodInfo(__delphirtti(TempConvertSoap), "CelsiusToFahrenheit", "",
"[ReturnName='CelsiusToFahrenheitResult']", IS_OPTN);
/* TempConvertHttpPost */
InvRegistry()->RegisterInterface(__delphirtti(TempConvertHttpPost), L"http://www.w3schools.com/webservices/", L"utf-8");
InvRegistry()->RegisterDefaultSOAPAction(__delphirtti(TempConvertHttpPost), L"");
}
#pragma startup RegTypes 32
Does someone have any idea why this might be happening? I tried on two other Samsung phones and it didn't work. The error that shuts the program down is "Segmentation fault(11)", and more precisely it stops at the following line of code in "System.pas" file :
u_strFromUTF8(PUChar(Dest), MaxDestChars, DestLen, MarshaledAString(Source), SourceBytes, ErrorConv);
Here is some info that I've found about the function:
u_strFromUTF8 - function that converts a UTF-8 string to UTF-16.
UCHAR is a Byte(in Delphi), so PUCHAR is a pointer to Byte.
I cannot se what could possibly go wrong with this function which apparently only converts a string.
So my question is why does the project work on Windows 32 bit version, but on Android it throws Segmentation fault(11)?
I hope I could find a solution for this problem. I will keep looking.
Thank you,
Zdravko Donev :)
UPDATE:
I disassembled the line:
InvRegistry()->RegisterInterface(__delphirtti(TempConvertSoap), L"http://www.w3schools.com/webservices/", L"utf-16");
to get :
TInvokableClassRegistry *Class = InvRegistry();
TTypeInfo *Info = __delphirtti(TempConvertSoap);
UnicodeString Namespace = "http://www.w3schools.com/webservices/";
UnicodeString WSDLEncoding = "utf-8";
Class->RegisterInterface(Info, Namespace, WSDLEncoding);
And I saw that the problem occurs when calling InvRegistry() function, but I still haven't found the problem as I cannot reach the source code of the function.
I found a solution.
I deleted the line
#pragma startup RegTypes 32
and called the method RegTypes() on my own when I create the form and it worked.

Android Passing Variables to another activity with # not working as expected

Ok I'm trying to create a link to an activity and it works. However passint it a variable isn't working with # charters:
String hashTagString = tempValues.getDescription().replaceAll("[#]+[A-Za-z0-9-_]+\\b", "$0");
Log.i(Utils.TAG, "hashTagString: " + hashTagString);
The launched activity:
String tag = getIntent().getData().getQueryParameter("tag");
Log.i(Utils.TAG, "tag: " + tag);
Log Cat:
02-24 13:12:04.293: I/PROJECTCARUSO(29591): hashTagString: Everyone loves #hashtags ! Take advantage of them by using them and clicking to search by them.
The activity it launches show this:
02-24 13:13:48.885: I/PROJECTCARUSO(29591): tag:
However if I set it with hard coded values it shows:
02-24 13:14:41.176: I/PROJECTCARUSO(29883): hashTagString: Everyone loves #hashtags ! Take advantage of them by using them and clicking to search by them.
02-24 13:14:41.637: I/PROJECTCARUSO(29883): tag: test
I'd like to pass the whole value, but if i cannot how can I remove all special charaters?
I don't think your regex is being evaluated correctlyTry using the following regex
\\#[A-Za-z0-9\\-_]+
You may need to double escape (\). The \b (word-boundary) at the end of your sequence isn't needed because it will break when it reaches a " anyway and the - in your character class needs escaping otherwise the regex is trying to evaluate a nonsense range instead of treating it as a char
Edit
Now you've clarified your issue the issue with getting a blank tagis this:
String tag = getIntent().getData().getQueryParameter("tag");
It should be
String tag = getIntent().getExtras().getString("tag");
and should be sent as
new Intent(...).putExtra("tag", hashTagString);
Try (\s|\A)#(\w+) that as a Java string is "(\\s|\\A)#(\\w+)".
You can test it in the following site: http://www.regexplanet.com/advanced/java/index.html

Calabash html report ignores errors during Before phase

When running the Calabash tests I get an error during the Before phase but the report exits with 0 code. It says that all the tests were failed because all the steps were skipped but the HTML report is green.
How can I make the report show that there was an error?
Updated: The exit code is correct. If it fails it returns a non 0 code. The problem is the html formatter. I'm running it with the following flag:
--format=html --out ./target/calabash-reports.html
Use
screenshot_and_raise "Error description"
line in side ruby step definitions where you want to raise the error
Eg:
Then /^I (?:press|touch) list item number (\d+)$/ do |index|
index = index.to_i
screenshot_and_raise "Index should be positive (was: #{index})" if (index<=0)
touch("tableViewCell index:#{index-1}")
sleep(STEP_PAUSE)
end

Categories

Resources