umano / AndroidSlidingUpPanel

This library provides a simple way to add a draggable sliding up panel (popularized by Google Music and Google Maps) to your Android application. Brought to you by Umano.
http://umano.me
Apache License 2.0
9.5k stars 2.27k forks source link

Error inflating class thrown when running ActivityInstrumentationTestCase2 based test case containing SlidingUpPanelLayout #259

Closed marcthomas2013 closed 10 years ago

marcthomas2013 commented 10 years ago

I have an activity that contains a MapView and the SlidingUpPanelLayout. It works perfectly when running as an application however, if I try to create a ActivityInstrumentationTestCase2 based test the test crashes on startup throwing the exception below.

Here is my test class public class MapViewActivityTest extends ActivityInstrumentationTestCase2 { private MapViewActivity activity;

public MapViewActivityTest() {
    super(MapViewActivity.class);
}

@Override
public void setUp() throws Exception {
    super.setUp();

    activity = getActivity();
}

@MediumTest
public void testActivityLaunchesSuccessfully() {
    assertNotNull(activity);
}

}

Here is the test case exception when run on my device. java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lsc.spear/com.lsc.spear.activities.MapViewActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class com.sothree.slidinguppanel.SlidingUpPanelLayout at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2413) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471) at android.app.ActivityThread.access$900(ActivityThread.java:175) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:146) at android.app.ActivityThread.main(ActivityThread.java:5602) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) at dalvik.system.NativeStart.main(Native Method) Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.sothree.slidinguppanel.SlidingUpPanelLayout at android.view.LayoutInflater.createView(LayoutInflater.java:626) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702) at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) at android.view.LayoutInflater.inflate(LayoutInflater.java:498) at android.view.LayoutInflater.inflate(LayoutInflater.java:398) at android.view.LayoutInflater.inflate(LayoutInflater.java:354) at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:366) at android.app.Activity.setContentView(Activity.java:2031) at com.lsc.spear.activities.MapViewActivity.onCreate(MapViewActivity.java:106) at android.app.Activity.performCreate(Activity.java:5451) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)             at android.app.ActivityThread.access$900(ActivityThread.java:175)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)             at android.os.Handler.dispatchMessage(Handler.java:102)             at android.os.Looper.loop(Looper.java:146)             at android.app.ActivityThread.main(ActivityThread.java:5602)             at java.lang.reflect.Method.invokeNative(Native Method)             at java.lang.reflect.Method.invoke(Method.java:515)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)             at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.constructNative(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at android.view.LayoutInflater.createView(LayoutInflater.java:600)             at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)             at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)             at android.view.LayoutInflater.inflate(LayoutInflater.java:498)             at android.view.LayoutInflater.inflate(LayoutInflater.java:398)             at android.view.LayoutInflater.inflate(LayoutInflater.java:354)             at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:366)             at android.app.Activity.setContentView(Activity.java:2031)             at com.lsc.spear.activities.MapViewActivity.onCreate(MapViewActivity.java:106)             at android.app.Activity.performCreate(Activity.java:5451)             at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)             at android.app.ActivityThread.access$900(ActivityThread.java:175)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)             at android.os.Handler.dispatchMessage(Handler.java:102)             at android.os.Looper.loop(Looper.java:146)             at android.app.ActivityThread.main(ActivityThread.java:5602)             at java.lang.reflect.Method.invokeNative(Native Method)             at java.lang.reflect.Method.invoke(Method.java:515)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)             at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation at com.sothree.slidinguppanel.ViewDragHelper.(ViewDragHelper.java:392) at com.sothree.slidinguppanel.ViewDragHelper.create(ViewDragHelper.java:348) at com.sothree.slidinguppanel.ViewDragHelper.create(ViewDragHelper.java:361) at com.sothree.slidinguppanel.SlidingUpPanelLayout.(SlidingUpPanelLayout.java:334) at com.sothree.slidinguppanel.SlidingUpPanelLayout.(SlidingUpPanelLayout.java:263)             at java.lang.reflect.Constructor.constructNative(Native Method)             at java.lang.reflect.Constructor.newInstance(Constructor.java:423)             at android.view.LayoutInflater.createView(LayoutInflater.java:600)             at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)             at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)             at android.view.LayoutInflater.inflate(LayoutInflater.java:498)             at android.view.LayoutInflater.inflate(LayoutInflater.java:398)             at android.view.LayoutInflater.inflate(LayoutInflater.java:354)             at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:366)             at android.app.Activity.setContentView(Activity.java:2031)             at com.lsc.spear.activities.MapViewActivity.onCreate(MapViewActivity.java:106)             at android.app.Activity.performCreate(Activity.java:5451)             at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)             at android.app.ActivityThread.access$900(ActivityThread.java:175)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)             at android.os.Handler.dispatchMessage(Handler.java:102)             at android.os.Looper.loop(Looper.java:146)             at android.app.ActivityThread.main(ActivityThread.java:5602)             at java.lang.reflect.Method.invokeNative(Native Method)             at java.lang.reflect.Method.invoke(Method.java:515)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)             at dalvik.system.NativeStart.main(Native Method)

Here is the layout contents

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawerLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="?android:attr/actionBarSize">

<com.sothree.slidinguppanel.SlidingUpPanelLayout xmlns:sothree="http://schemas.android.com/apk/res-auto"
    android:id="@+id/slidingUpLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="bottom"
    sothree:dragView="@+id/header"
    sothree:panelHeight="68dp"
    sothree:shadowHeight="4dp">

    <fragment
        android:id="@+id/mapView"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!-- SLIDING LAYOUT -->
    <LinearLayout
        android:id="@+id/dragView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#eeeeee"
        android:clickable="true"
        android:focusable="false"
        android:orientation="vertical">

        <RelativeLayout
            android:id="@+id/header"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="10dp">

            <TextView
                android:id="@+id/localName"
                android:layout_width="200dp"
                android:layout_height="wrap_content"
                android:ellipsize="marquee"
                android:fadingEdge="horizontal"
                android:maxLines="1"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/elr"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/localName"
                android:gravity="top"
                android:text="ELR"
                android:textSize="14sp" />

            <Button
                android:id="@+id/expandSlidingLayout"
                style="?android:attr/buttonStyleSmall"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:background="@drawable/ic_action_collapse"
                android:gravity="center_vertical|right"
                android:paddingLeft="20dp"
                android:paddingRight="20dp"
                android:textSize="14sp" />

            <Button
                android:id="@+id/directionsButton"
                style="?android:attr/buttonStyleSmall"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toLeftOf="@+id/expandSlidingLayout"
                android:background="@drawable/ic_action_directions"
                android:onClick="onDirections" />

            <Button
                android:id="@+id/augmentedRealityButton"
                style="?android:attr/buttonStyleSmall"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toLeftOf="@+id/directionsButton"
                android:background="@drawable/ic_action_picture"
                android:onClick="doAugmentedReality" />

            <Button
                android:id="@+id/addCommentButton"
                android:layout_width="47dp"
                android:layout_height="wrap_content"
                android:layout_below="@+id/directionsButton"
                android:layout_marginTop="20dp"
                android:background="@drawable/ic_action_new"
                android:gravity="top|right"
                android:textSize="14sp" />

            <Button
                android:id="@+id/addPhotoButton"
                android:layout_width="47dp"
                android:layout_height="wrap_content"
                android:layout_below="@+id/directionsButton"
                android:layout_marginTop="20dp"
                android:layout_toRightOf="@+id/addCommentButton"
                android:background="@drawable/ic_action_camera"
                android:gravity="top|right"
                android:onClick="onAddPhoto"
                android:textSize="14sp" />

            <ListView
                android:id="@+id/commentListView"
                android:layout_width="match_parent"
                android:layout_height="188dp"
                android:layout_below="@+id/addCommentButton" />

            <GridView xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/photoListView"
                android:layout_width="match_parent"
                android:layout_height="217dp"
                android:layout_below="@+id/commentListView"
                android:columnWidth="90dp"
                android:gravity="center"
                android:horizontalSpacing="10dp"
                android:numColumns="auto_fit"
                android:stretchMode="columnWidth"
                android:verticalSpacing="10dp" />
        </RelativeLayout>
    </LinearLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>

<!-- This ListView provides the layout for the navigation drawer on the left hand side. It is
completely separate to the sliding up panel and integrates with the action bar.
-->
<ListView
    android:id="@+id/navigationDrawerView"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="#333"
    android:choiceMode="singleChoice"
    android:divider="@android:color/transparent"
    android:dividerHeight="0dp" />

</android.support.v4.widget.DrawerLayout>

tokudu commented 10 years ago

This is unlikely a library issue. Have a look here: http://stackoverflow.com/questions/9199992/android-instrumentation-testing-illegalaccesserror