Find View id in source code from Crashlytics crash report - android

I release an app with Crashlytics inside to send crash report, here is report I received:
"Fatal Exception: java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification.
Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. Make sure your adapter calls notifyDataSetChanged() when its content changes. [in ListView(2131493375, class android.widget.ListView) with Adapter(class com.nhatnq.app.b.cr)]
at android.widget.ListView.layoutChildren(ListView.java)
at android.widget.AbsListView.onLayout(AbsListView.java)
..."
I want to know which Apdater/ListView got this crash, so I want to trace from these things:
"com.nhatnq.app.b.cr": package name is hidden, I can not know. In my app, I have an "ExpandableContactAdapter extends BaseExpandableListAdapter" in package com.nhatnq.app.contact.ExpandableContactAdapter.java, and some Fragments which include adapter such as com.nhatnq.app.fragment.HistoryFragment$ExpandableHistoryAdapter,
com.nhatnq.app.fragment.MessageFragment$ExpandableMessageAdapter,...
ListView(2131493375): this is ID of ListView. I convert this from dec to hex, then find in my local source code (in R.java), but not found this resource ID. Perhaps ID is encoded by time key when release.
What I need to check here, to find correct ListView/Adapter then I can check? Now I have 5 adapters and really do not know what need to check, as this issue only happen on some phones.
I work in a team, other guy take responsible for releasing app from team source code.

Your release "guy" is probably using Proguard or something similar, so the class name is obsfucated (class com.nhatnq.app.b.cr). This is a procedure makes it harder for someone to reverse engineer your code.
You need to ask him to Retrace (or deobfuscate) the code so you can properly identify the class. He should retain files for doing this, in the case of Proguard, here is a reference:
http://simplyadvanced.net/blog/android-how-to-decode-proguards-obfuscated-code-from-stack-trace/

Related

Proguard rule for Huawei push client

I have Unable to create application im.app.android.core.AppDemoApplication: e3.b: com.pushserver.android.huaweiPushClient cant cast com.myApp.android.push_lib.huawei.HcmPushClient to PushClient error
What proguard rule should I add? I have tried -keep class com.myApp.android.push_lib.** { *; } but after that I just see the blank screen - no crash, just stuck when trying to start.
Not really an answer, but too long for a comment. I'll update this answer in case we make progress.
1. What is the "normal bug"?
can't cast com.myApp.android.push_lib.huawei.HcmPushClient to PushClient
This means that somewhere in your code you are assigning/passing an instance of HcmPushClient to something that is expecting it to be a PushClient. I would assume that PushClient is some class that you defined in your project, but is does not extend from HcmPushClient. Try to find this piece of code and fix it or add it here to your question.
2. What does ProGuard have to do with this?
Actually, I think not much. If ProGuard would create this error, the message would look more like
can't cast com.myApp.android.push_lib.a.b to c
But since all class names in the error message are the original ones, it does not seem like ProGuard is making issues here. BUT: You can still decypher the message a little bit, because this part is obfuscated:
Unable to create application im.app.android.core.AppDemoApplication: e3.b:
e3.b refers to a class that was obfuscated by ProGuard. To find out what class it is, you can check the file /build/outputs/mapping/release/mapping.txt in your project folder. This is a simple text file that stores the information what class name was renamed to what obfuscated name. In this file search for -> e3 to find the class that was renamed to e3. Somewhere close to this line, you should also be able to find out what exactly e3.b is. Could be a method, could also be a member variable or an inner class.
I hope these two points will bring you closer to make the app run.

Is there a way to trace who invoked onNext() on a Subject, in RxJava(2)?

I am developing an Android app (It doesn't matter though) using RxJava2, and in some singleton there are some PublishProcessors.
And there are a lot of .onNext() calls on these PublishProcessors all over the project.
Now in order to debug, I need to know, on every .onNext() called, which line in my project invoked this .onNext().
Is there a way in RxJava(2) that I can achieve this?
I think you can use Frames tab in Debug menu.
For example, in this case, MainActivity line 18 trigger onNext
Ah, thanks to #PhanVanLinh, I found a solution that worked for me.
(Actually it has pretty much nothing to do with RxJava...)
You just need to print the stacktrace using Thread.currentThread.stackTrace and print it to your own string inside doOnNext(), but remember to do it before .observeOn() so that the thread won't switch, it must stay at the original thread that called .onNext(), otherwise you won't get meaningful information.
Then you will know which line that called .onNext().

Keep sections are being removed on generation

I am using GreenDAO v1.2.0 to generate entity classes for an Android app.
I have set enableKeepSectionsByDefault() on my schema, and am getting these comment lines in my generated classes:
// KEEP METHODS - put your custom methods here
// KEEP METHODS END
I have put some custom methods between the comments, but the custom methods are removed every time I regenerate.
Is there something else I need to do to get this to work?
There is a parsing bug in greenDAO that will cause some or all of your KEEP METHODS to get wiped out by running the DaoGenerator.generateAll() method (even with schema.enableKeepSectionsByDefault() enabled)
The bug is that your Entity class (the one you have added custom imports, fields or methods to) REQUIRES a blank line at the end of the file.
for example
...
//KEEP_METHODS_END
}
... end of file
will fail, while
...
//KEEP_METHODS_END
}
... end of file
will work. Nasty little bug. Until it's fixed (if ever), ensure that your entity classes have a blank line at the end.
Hope this saves someone the torment I have experienced.
Ensure that the last line of the generated entity class is blank.
You need to call the schema.enableKeepSectionsByDefault();.

How to find a code behind a view in hierarchyviewer

Android hierarchyviewer shows a ID for each view in the tree view.
The ID is a # sign followed by a number, e.g #4051d698
In android documentation the purpose of this number is explained as "pointer to view object".
Assuming one has the sources of a very big android project like AOSP.
How can one figure out what is the java source code behind the view by using this ID?
Is there a method I can invoke that tells me what is the R.java entry that is bound to this pointer?
How can one figure out what is the java source code behind the view by using this ID?
You can't, at least without a debugger. If you are used to C/C++ development, that hexadecimal value is roughly analogous to a pointer. Just because you have a pointer to a hunk of RAM in C/C++ does not mean that you can determine the source code behind the object resident at that pointer.
Now, it is possible that there is a way in a debugger to supply this hex value and the debugger will match that up to an object and source code. I am not an Eclipse expert, or an expert on another other IDE debuggers, to know whether or not there is a means to do this. However, even if can do this, it will probably only give you the source of the class of the object (e.g., if the View is a ListView, it might send you to the ListView source code), not the source code of what created the object.
Is there a method I can invoke that tells me what is the R.java entry that is bound to this pointer?
First, R.java is not "bound" to any pointers.
Second, the View in question may not have come from an inflated layout. It might have been created directly in Java code instead.
If the View has an "View object ID" (e.g., id/content), that can better help you find where it came from, as that will be an android:id value, possibly from your layout resources.

ClassLoader.class "source not found" error when instantiating a database class in android

I am trying to implement Content Providers and Cursor Loaders to get away from cursors as recommended by Android/Google. However, I'm having a terrible time of it. I'm using the tutorials at http://mobile.tutsplus.com/tutorials/android/android-sdk_content-providers/ as my guide and the simplest thing just isn't working. At the beginning of my Activity, I'm doing the following:
SQLData entry = new SQLData(getApplicationContext());
I've also tried
SQLData entry = new SQLData(this);
SQLData is the name of my database class. What I'd like to do after this line of code is create and populate the database using the methods from the content provider class I've created. However, when I try to move past this line in the debugger, a ClassLoader.class window opens, with the message "source not found". I've reloaded and refreshed and cleaned my package, but this doesn't help. I'm happy to provide all the code for my database and content provider classes, but I'm not sure that's what's needed here. Does anyone know how to approach this issue?
Thanks very much!
In android, or any java dev; you may find it more useful to write JUnit tests and put lots of
Log.v(TAG, "message about " + variable);
in your code instead of using the debugger...
I write Java code as my job and use the debug option maybe twice a year as a last resort...
the JUnit tests get my errors out and save me TONS of time, stepping through code in the debugger can be a very time consuming thing...
just a tip, and it may just be my personal pref...

Categories

Resources