Testing Android with Robolectric: Not Recognizing the Facebook SDK

We are trying to use the Robolectric testing platform in Android Studio to test the Facebook API. The Facebook login button works so that the Facebook API works. However, the following test fails:

    package com.airportapp.test.Models;

    import android.app.Activity;

    import org.junit.Assert;
    import org.junit.Before;
    import org.junit.Test;
    import org.junit.runner.RunWith;
    import org.robolectric.annotation.Config;
    import org.robolectric.Robolectric;
    import com.airportapp.test.MyRobolectricTestRunner;
    import com.airportapp.LoginActivity;

    import static org.junit.Assert.assertFalse;
    import static org.junit.Assert.assertTrue;

    @RunWith(MyRobolectricTestRunner.class)

    public class LoginActivityTest {
            @Before
            public void setup() {
            //do whatever is necessary before every test
            }

    @Test
    public void testActivityFound() {
            Activity activity = Robolectric.buildActivity(LoginActivity.class).create().get();

            Assert.assertNotNull(activity);
            }
    }

And the error is that Android Studio could not find the android.support file when we run the tests. You can see the error here:enter image description here

Another error that appears: android.view.InflateException: XML file app / src / main / res / layout / activity_login.xml line # -1 (sorry, not yet implemented): error inflating class com.facebook.widget.LoginButton

So, Android Studio doesnโ€™t like the facebook login button :( But it works ... We think we need to import something, but we donโ€™t know where to put it.

+4
1

InflateException , Robolectric SDK Facebook. , project.properties , SDK Facebook. , :

android.library.reference.1={Path}

{Path} project.properties , AndroidManifest.xml SDK Facebook. ../../build/intermediates/exploded-aar/com.facebook.android/facebook/3.21.0.

, Android, , Robolectric. : . , project.properties . , Robolectric Android-. project.properties , AndroidManifest.xml, .

; . , , , Gradle . .

+1

All Articles