How do I find the right sources for an Android device?

I want to look at sources in Android to understand the reason for the error. I have an Android device with version 4.4.4

which is the same as API 19

. I have downloaded the sources for API level 19 (via sdk manager) and wanted to find the code that is causing the error.
In logcat, I have an error:

12-16 16:51:03.790: E/AndroidRuntime(10349): java.lang.NullPointerException
12-16 16:51:03.790: E/AndroidRuntime(10349):    at android.widget.TextView.checkForRelayout(TextView.java:6596)
12-16 16:51:03.790: E/AndroidRuntime(10349):    at android.widget.TextView.onRtlPropertiesChanged(TextView.java:8716)
12-16 16:51:03.790: E/AndroidRuntime(10349):    at android.view.View.resolvePadding(View.java:12538)

      

But the problem is that inside line 6596 of the TextView class:

} else {

      

Line 8716 is a comment. So the courses do not match the error. How do you find the right sources?

Also if you register a device Build.VERSION.SDK_INT is 19

. Device - Sony Xperia tablet

.

Full logarithm for 12-16 17:30:43

.401: E/AndroidRuntime(19327): java.lang.NullPointerException
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.widget.TextView.checkForRelayout(TextView.java:6596)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.widget.TextView.onRtlPropertiesChanged(TextView.java:8716)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.View.resolvePadding(View.java:12538)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.View.resolveRtlPropertiesIfNeeded(View.java:12289)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.View.measure(View.java:16639)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at com.cooperok.gui.views.tablefixheader.TableFixHeaders.makeView(TableFixHeaders.java:741)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at com.cooperok.gui.views.tablefixheader.TableFixHeaders.makeAndSetup(TableFixHeaders.java:698)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at com.cooperok.gui.views.tablefixheader.TableFixHeaders.onLayout(TableFixHeaders.java:601)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.View.layout(View.java:14965)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.View.layout(View.java:14965)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.View.layout(View.java:14965)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.View.layout(View.java:14965)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.View.layout(View.java:14965)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.View.layout(View.java:14965)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.View.layout(View.java:14965)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.View.layout(View.java:14965)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1987)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1744)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5622)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.Choreographer.doCallbacks(Choreographer.java:574)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.Choreographer.doFrame(Choreographer.java:544)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.os.Handler.handleCallback(Handler.java:733)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.os.Handler.dispatchMessage(Handler.java:95)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.os.Looper.loop(Looper.java:212)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at android.app.ActivityThread.main(ActivityThread.java:5135)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at java.lang.reflect.Method.invokeNative(Native Method)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at java.lang.reflect.Method.invoke(Method.java:515)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
12-16 17:30:43.401: E/AndroidRuntime(19327):    at dalvik.system.NativeStart.main(Native Method)

      

+3


source to share


2 answers


To solve my problem, I looked at the original android source and found that there are only two possible NullPointerException variants, so it was easy to guess where the problem is

/**
 * Check whether entirely new text requires a new view layout
 * or merely a new text layout.
 */
private void checkForRelayout() {
    // If we have a fixed width, we can just swap in a new text layout
    // if the text height stays the same or if the view height is fixed.

    if ((mLayoutParams.width != LayoutParams.WRAP_CONTENT ||
            (mMaxWidthMode == mMinWidthMode && mMaxWidth == mMinWidth)) &&
            (mHint == null || mHintLayout != null) &&
            (mRight - mLeft - getCompoundPaddingLeft() - getCompoundPaddingRight() > 0)) {
        // Static width, so try making a new text layout.

        int oldht = mLayout.getHeight();
        int want = mLayout.getWidth();
        int hintWant = mHintLayout == null ? 0 : mHintLayout.getWidth();

        /*
         * No need to bring the text into view, since the size is not
         * changing (unless we do the requestLayout(), in which case it
         * will happen at measure).
         */
        makeNewLayout(want, hintWant, UNKNOWN_BORING, UNKNOWN_BORING,
                      mRight - mLeft - getCompoundPaddingLeft() - getCompoundPaddingRight(),
                      false);

        if (mEllipsize != TextUtils.TruncateAt.MARQUEE) {
            // In a fixed-height view, so use our new text layout.
            if (mLayoutParams.height != LayoutParams.WRAP_CONTENT &&
                mLayoutParams.height != LayoutParams.MATCH_PARENT) {
                invalidate();
                return;
            }

            // Dynamic height, but height has stayed the same,
            // so use our new text layout.
            if (mLayout.getHeight() == oldht &&
                (mHintLayout == null || mHintLayout.getHeight() == oldht)) {
                invalidate();
                return;
            }
        }

        // We lose: the height has changed and we have a dynamic height.
        // Request a new view layout using our new text layout.
        requestLayout();
        invalidate();
    } else {
        // Dynamic width, so we have no choice but to request a new
        // view layout with a new text layout.
        nullLayouts();
        requestLayout();
        invalidate();
    }
}

      



In my case the TextView was created programmatically and mLayoutParams was null, so the problem was solved by setting the LayoutParams to view.
But it's awful that sellers can change the source of Android and not show those changes (I didn't actually find any information about Sony). I thought they only change the kernel.

0


source


To find the correct row of sources, you must have one Google Nexus device - pure Android devices.



Manufacturers are changing Android sources for their devices. This is causing the wrong line number in logcat.

+1


source







All Articles