I have two problems, one you described below and a different one.
First, the one you described below...take the android-support.v4.jar
reference out of your automation project libraries and have it refer
to your product code. That tends to get rid of the error below. But it
produces a second issue: the problem that I haven't discovered a
solution to is that when I try to compile my test automation I get
"Bound mismatch: The type [class that extends FragmentActivity] is not
a valid substitute for the bounded parameter <T extends Activity> of
the type ActivityInstrumentationTestCase2<T>". It seems that despite
ActivityInstrumentationTestCase2 allowing for generics, it won't allow
anything but a type that extends Activity directly. FragementActivity
does extend Activity and so I figured that the [class that extends
FragmentActivity] should be applicable to
ActivityInstrumentationTestClass2. Well, it's not and I'm not sure of
another way to write any automation at this point. It doesn't look
like the SDK test classes have been updated to support these other
Activity based classes.

Has anyone else been able to get this to work?

On Apr 7, 8:33 am, securelpb <a...@securesmith.net> wrote:
> I have a problem executing android unit tests against android
> applications that utilize the recently released Fragment support API.
> When the test is run against aFragmentActivitythe following error
> shows up in the log and the class fails to load. When run against an
> identical class, but one derived from Activity the test works fine.
> Both classes work correctly as apps! Meaning that when simply invoked
> they both display their layout and function correctly. The support jar
> is part of the build path and included in the project.
>
> The problem I have is that the only way to utilize fragments (and
> support pre3.0 android) is to utilizeFragmentActivity, but if that
> excludes automated testing then what good is this library.
>
> 4-05 18:00:11.276: WARN/dalvikvm(1095): Class resolved by unexpected
> DEX: Lcom/example/android/app/FragmentLayoutSupport;(0x406351a0):
> 0x12e5c8 ref [Landroid/support/v4/app/FragmentActivity;] Landroid/
> support/v4/app/FragmentActivity;(0x406351a0):0x12e440
> 04-05 18:00:11.276: WARN/dalvikvm(1095): (Lcom/example/android/app/
> FragmentLayoutSupport; had used a different 
> Landroid/support/v4/app/FragmentActivity; during pre-verification)
> 04-05 18:00:11.286: WARN/dalvikvm(1095): Unable to resolve superclass
> of Lcom/example/android/app/FragmentLayoutSupport; (49)
> 04-05 18:00:11.286: WARN/dalvikvm(1095): Link of class 'Lcom/example/
> android/app/FragmentLayoutSupport;' failed
> 04-05 18:00:11.286: ERROR/dalvikvm(1095): Could not find class
> 'com.example.android.app.FragmentLayoutSupport', referenced from
> method com.example.android.app.test.FrameLayoutTest.<init>
> 04-05 18:00:11.286: WARN/dalvikvm(1095): VFY: unable to resolve const-
> class 131 (Lcom/example/android/app/FragmentLayoutSupport;) in Lcom/
> example/android/app/test/FrameLayoutTest;
>
> Here is the code I constructed to demonstrate the issue. The test case
> simply tries to instantiate the class under test:
>
> FrameLayoutTest.java
> /*
>   *This test case uses  ActivityInstrumentationTestCase2, but I've
> also duplicated this failure
>  * with ServiceTestCase while attempting to test a working service in
> my app.
> */
> public class FrameLayoutTest extends
>            ActivityInstrumentationTestCase2<FragmentLayoutSupport> {
>         public FrameLayoutTest() {
>             super(FragmentLayoutSupport.class);
>         }
>
>     public void testActivityTestCaseSetUpProperly() {
>         assertNotNull("activity should be launched successfully",
> getActivity());
>     }
>
> }
>
> The two classes I have created are as follows and fragment_layout is
> an empty LinearLayout:
>
> FrameLayout.java
> public class FragmentLayout extends Activity {
>     @Override
>     protected void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>
>         setContentView(R.layout.fragment_layout);
>     }
>
> }
>
> And
>
> FragmentLayoutSupport.java
> public class FragmentLayoutSupport extendsFragmentActivity{
>     @Override
>     protected void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>
>         setContentView(R.layout.fragment_layout);
>     }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to