"GooglePlayServicesNotAvailableException" with robolectric:4.6.1

Viewed 183

Can anyone please suggest how to fix it or confirm that it won't work?

My test:

@RunWith(AndroidJUnit4.class)
public class DemoTest {

@Test
public void testApp() throws Exception {
    // ...
    Context context = ApplicationProvider.getApplicationContext();
    ProviderInstaller.installIfNeeded(context);  <<<--------- Throws exception here
    // ...
}

}

Stack trace:

com.google.android.gms.common.GooglePlayServicesNotAvailableException at com.google.android.gms.common.GooglePlayServicesUtilLight.ensurePlayServicesAvailable(com.google.android.gms:play-services-basement@@17.3.0:73) at com.google.android.gms.common.GoogleApiAvailabilityLight.verifyGooglePlayServicesIsAvailable(com.google.android.gms:play-services-basement@@17.3.0:9) at com.google.android.gms.security.ProviderInstaller.installIfNeeded(com.google.android.gms:play-services-basement@@17.3.0:3) ...

In build.gradle

testImplementation "org.robolectric:robolectric:4.6.1"
testImplementation "org.robolectric:shadows-play-services:3.3.2"
0 Answers
Related