1

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?

sr90
  • 67
  • 1
  • 7
  • Check this link: http://stackoverflow.com/questions/19874882/android-view-inflateexception-binary-xml-file-error-inflating-class-fragment It recommends changing your xml class reference to `class = "com.fragment.NavigationDrawerFragment"` instead of `android:name` See if that does the trick for you. – CubeJockey Apr 27 '15 at 20:18
  • I tried this previously with no positive results – sr90 Apr 27 '15 at 20:23
  • Can you please post the LogCat error, because error inflating class "fragment" is not related to your Java code – TootsieRockNRoll Apr 27 '15 at 20:31
  • android.view.InflateException: Binary XML file line #12: Error inflating class fragment at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:770) – sr90 Apr 27 '15 at 20:47

0 Answers0