opened
jaredsburrows
username_0
### Description
NullPointer in Application Class

### Steps to Reproduce
Class:
```
public final class AppApplication extends Application {

    private static Context context;

    @Override
    public void onCreate() {

        context = this.getApplicationContext(); // NullPointerException
    }

    public static Context getContext() {
        return context;
    }
}
```

TestClass:
```
public class AppApplicationTest extends RoboTestBase {

    private AppApplication sut = new AppApplication();

    @Test
    public void testOnCreate() {
        sut.onCreate();
        // assert sdks are initialized
    }
}
```

#### Error Output:
```
    java.lang.NullPointerException
        at android.content.ContextWrapper.getApplicationContext(ContextWrapper.java:105)
```

### Robolectric & Android Version
Robolectric: 3.1-rc1
Android: Any api level
NullPointerException - 'getApplicationContext()' in Application
issue
closed
jongerrish
username_1
issue
created
jongerrish
username_1
All contexts must have an attached base context now (we're using more real framework code rather than fake shadow implementations).

Robolectric.buildService(MyService.class)
Robolectric.buildActivity(MyActivity.class)
ApplicationTestUtil.buildApplication(MyApplication.class, someOtherContext)
comment