ads

Affichage des articles dont le libellé est class. Afficher tous les articles
Affichage des articles dont le libellé est class. Afficher tous les articles

samedi 29 août 2015

android.view.InflateException: Binary XML file line #1: Error inflating class include



I have a certain App that was using different layouts for different activities, but much of the xml content was same. So I moved the content to a common xml and included that in the different layouts.

This is the common layout xml:


Code:


<LinearLayout xmlns:android="http;//schemas.android.com/apk/res/android"
              xmlns:app="http;//schemas.android.com/apk/res-auto"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:orientation="vertical"
              android:background="@color/background_color">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="0dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/img_newslist"
            android:layout_width="35dp"
            android:layout_height="35dp"
            android:scaleType="centerCrop"
            android:layout_margin="0dp"
            android:layout_gravity="center_vertical" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="5dp"
            android:orientation="vertical"
            android:gravity="center_vertical">

            <TextView
                android:id="@+id/txt_newslistheading"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:maxLines="2"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textColor="@color/text_color"
                android:textSize="14sp"
                android:text="Heading"/>

            <TextView
                android:id="@+id/txt_newslistdate"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:textColor="@color/text_color"
                android:text="Date"
                android:visibility="invisible"/>

        </LinearLayout>

    </LinearLayout>

</LinearLayout>


This is the layout xml that includes the above xml:


Code:


<include
    android:layout="@layout/lsv_item_list"
    android:id="@+id/lsv_item_recent"
    xmlns:android="http;//schemas.android.com/apk/res/android"
    xmlns:app="http;//schemas.android.com/apk/res-auto"/>


With these changes the app is failing at run time with the following error:


Quote:









08-29 13:48:59.717 32104-32104/com.apps.nis D/AndroidRuntime﹕ Shutting down VM
08-29 13:48:59.717 32104-32104/com.apps.nis E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.apps.nis, PID: 32104
android.view.InflateException: Binary XML file line #1: Error inflating class include
at android.view.LayoutInflater.createViewFromTag(Layo utInflater.java:757)
at android.view.LayoutInflater.inflate(LayoutInflater .java:482)
at android.view.LayoutInflater.inflate(LayoutInflater .java:414)
at android.view.LayoutInflater.inflate(LayoutInflater .java:365)
at com.apps.nis.Adapter_Recent.getView(Adapter_Recent .java:43)
at android.widget.AbsListView.obtainView(AbsListView. java:2347)
at android.widget.ListView.makeAndAddView(ListView.ja va:1864)
at android.widget.ListView.fillDown(ListView.java:698 )
at android.widget.ListView.fillFromTop(ListView.java: 759)
at android.widget.ListView.layoutChildren(ListView.ja va:1673)
at android.widget.AbsListView.onLayout(AbsListView.ja va:2151)
at android.view.View.layout(View.java:15671)
at android.view.ViewGroup.layout(ViewGroup.java:5038)
at android.widget.RelativeLayout.onLayout(RelativeLay out.java:1076)
at android.view.View.layout(View.java:15671)
at android.view.ViewGroup.layout(ViewGroup.java:5038)
at android.widget.FrameLayout.layoutChildren(FrameLay out.java:579)
at android.widget.FrameLayout.onLayout(FrameLayout.ja va:514)
at android.view.View.layout(View.java:15671)
at android.view.ViewGroup.layout(ViewGroup.java:5038)
at android.support.v4.view.ViewPager.onLayout(ViewPag er.java:1594)
at android.view.View.layout(View.java:15671)
at android.view.ViewGroup.layout(ViewGroup.java:5038)
at android.widget.RelativeLayout.onLayout(RelativeLay out.java:1076)
at android.view.View.layout(View.java:15671)
at android.view.ViewGroup.layout(ViewGroup.java:5038)
at android.widget.FrameLayout.layoutChildren(FrameLay out.java:579)
at android.widget.FrameLayout.onLayout(FrameLayout.ja va:514)
at android.view.View.layout(View.java:15671)
at android.view.ViewGroup.layout(ViewGroup.java:5038)
at android.widget.LinearLayout.setChildFrame(LinearLa yout.java:1703)
at android.widget.LinearLayout.layoutVertical(LinearL ayout.java:1557)
at android.widget.LinearLayout.onLayout(LinearLayout. java:1466)
at android.view.View.layout(View.java:15671)
at android.view.ViewGroup.layout(ViewGroup.java:5038)
at android.widget.FrameLayout.layoutChildren(FrameLay out.java:579)
at android.widget.FrameLayout.onLayout(FrameLayout.ja va:514)
at android.view.View.layout(View.java:15671)
at android.view.ViewGroup.layout(ViewGroup.java:5038)
at android.widget.LinearLayout.setChildFrame(LinearLa yout.java:1703)
at android.widget.LinearLayout.layoutVertical(LinearL ayout.java:1557)
at android.widget.LinearLayout.onLayout(LinearLayout. java:1466)
at android.view.View.layout(View.java:15671)
at android.view.ViewGroup.layout(ViewGroup.java:5038)
at android.widget.FrameLayout.layoutChildren(FrameLay out.java:579)
at android.widget.FrameLayout.onLayout(FrameLayout.ja va:514)
at android.view.View.layout(View.java:15671)
at android.view.ViewGroup.layout(ViewGroup.java:5038)
at android.view.ViewRootImpl.performLayout(ViewRootIm pl.java:2086)
at android.view.ViewRootImpl.performTraversals(ViewRo otImpl.java:1843)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl .java:1061)
at android.view.ViewRootImpl$TraversalRunnable.run(Vi ewRootImpl.java:5885)
at android.view.Choreographer$CallbackRecord.run(Chor eographer.java:767)
at android.view.Choreographer.doCallbacks(Choreograph er.java:580)
at android.view.Choreographer.doFrame(Choreographer.j ava:550)
at android.view.Choreographer$FrameDisplayEventReceiv er.run(Choreographer.java:753)
at android.os.Handler.handleCallback(Handler.java:739 )
at android.os.Handler.dispatchMessage(Handler.java:95 )
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.jav a:5257)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:698)
Caused by: java.lang.Cla




Previously the app was working fine. Can somebody help me understand what I am doing wrong? The relevant code that is failing is as follows:


Code:


                public View getView(final int position, View convertView, ViewGroup parent) {
                        View view = convertView;
                        ViewHolder holder;
                        if (view == null) {
                                LayoutInflater inflater = (LayoutInflater) activity
                                                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                                view = inflater.inflate(row, null);

                                holder = new ViewHolder();
                                view.setTag(holder);
                        } else {
                                holder = (ViewHolder) view.getTag();
                        }

                        if ((itemsLatest == null) || ((position + 1) > itemsLatest.size()))
                                return view;

        if (position % 2 == 1) {
            view.setBackgroundColor(row2Color);
        } else {
            view.setBackgroundColor(row1Color);
        }

                        objLatestBean = itemsLatest.get(position);

                        holder.txt_newsheadinglatest=(TextView)view.findViewById(R.id.txt_newslistheading);
                        holder.txt_newsdatelatest=(TextView)view.findViewById(R.id.txt_newslistdate);
                        holder.img_newslatest=(ImageView)view.findViewById(R.id.img_newslist);
                       
                        holder.txt_newsheadinglatest.setText(objLatestBean.getNewsHeading().toString());
                        holder.txt_newsdatelatest.setText(objLatestBean.getNewsDate().toString());

                        imageLoader.DisplayImage(Constant.getServerImageThumbs () + objLatestBean.getNewsImage().toString(), holder.img_newslatest);       
                       
                        return view;
                       
                }


PS: I have changed : to ; in the URL above. That is not an error.



jeudi 27 août 2015

Hook on method in class that is dynamically loaded.



Hi,

I'm trying to hook on a method that belongs to a class that is dynamically loaded from a .dex file (via DexClassLoader). How can I hook on this. I seen comments before where people say to hook using the DexClassLoader instead of standard class loader we have available to us through Xposed. (http://stackoverflow.com/a/28635776/3899529) How can I do this? I'm finding it hard to find examples online? How do I grab an instance and use this instance for hooking? Does anyone have a small snippet example please?
Thanks.



mardi 25 août 2015

Outer class object using XposedHelpers.getSurroundingThis



In my module, I need to replace the method (onReceive) of an inner class (Receiver). Inside that method, I'm using XposedHelpers.getSurroundingThis to reference the instance object of the outer class (SeekBarVolumizer). In short, the method getSurroundingThis always returns the instance object of the class SeekBarVolumizer. The situation is similar to figure 1.

It all works fine except for some Xperia devices on Android 5.1 that the class SeekBarVolumizer is also used in another class SomcExpandedVolumeSliders as in figure 2. This time, I found that the method getSurroundingThis returns the instance object of the class VolumeSliderInfo instead. In this case, the replaced method will never be able to reference the correct object and its variable and method.

Is this an Xposed issue or just that I program incorrectly?

Figure 1:

Quote:









public class SeekBarVolumizer {
...
private final class Receiver {
public void onReceive(Context context, Intent intent) {
/* codes here to be replaced */
}
}
}





Figure 2:

Quote:









public class SomcExpandedVolumeSliders {
...
private static class VolumeSliderInfo {
private SeekBarVolumizer mSeekBarVolumizer;
...
}
}