lundi 27 avril 2015

Why am i getting Error inflating class fragment in my android test?

When i run my application i receive no errors, but when i try to run a test using the activity that includes the fragment i receive the inflation error.

I have been trying to resolve this for the past few hours and i am getting no where.

This is my fragment part of my xml.

<fragment
    android:layout_marginTop="30dp"
    android:layout_gravity="center_horizontal"
    android:layout_width="300dip"
    android:layout_height="300dip"
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    />

And this is the test that fails.

public class testResultsActivity extends ActivityUnitTestCase<ResultsPage>
{

ResultsPage resultsPage;
public testResultsActivity()
{
    super(ResultsPage.class);
}

@Override
protected void setUp() throws Exception {
    super.setUp();
    Intent intent = new Intent(getInstrumentation().getTargetContext(),
            ResultsPage.class);
    startActivity(intent, null, null);
    resultsPage = getActivity();
}

@SmallTest
public void testResultsPage()
{
    assertNotNull(resultsPage.findViewById(R.id.map));
    assertNotNull(resultsPage.findViewById(R.id.ratingBar));
}



}

Can anyone tell me what is actually causing this and how i can go about fixing/ avoiding it?

Aucun commentaire:

Enregistrer un commentaire