Q:

View ClassCastException during Fragment injection

Given I'm using AndroidAnnotations like this:
@EFragment(R.layout.fragment_music_home2)
public class MusicHomeFragment extends AppsBasedHomeFragment {
    @ViewById
    protected ExtRecyclerView pager;
}

Then the generated code for MusicHomeFragment_ looks like this at one point:
    pager = ((ExtRecyclerView) hasViews.findViewById(com.company. R.id.pager));

Which results in the stack trace as below:
java.lang. ClassCastException: com.company.view. ExtRecyclerView_ cannot be cast to com.company.view. ExtRecyclerView
    at com.company.music. MusicHomeFragment_.onViewChanged(MusicHomeFragment_.java:97)
    at org.androidannotations.api.view. OnViewChangedNotifier.notifyViewChanged(OnViewChangedNotifier.java:41)
    at com.company.music. MusicHomeFragment_.onViewCreated(MusicHomeFragment_.java:85)
    at android.support.v4.app. FragmentManagerImpl.moveToState(FragmentManager.java:973)
    at android.support.v4.app. FragmentManagerImpl.moveToState(FragmentManager.java:1138)
    at android.support.v4.app. FragmentManagerImpl.moveToState(FragmentManager.java:1120)
    at android.support.v4.app. FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1929)
    at android.support.v4.app. FragmentActivity.onStart(FragmentActivity.java:547)
    at com.company.utils. BaseActivity.onStart(BaseActivity.java:104)
    at android.app. Instrumentation.callActivityOnStart(Instrumentation.java:1171)
    at android.app. Activity.performStart(Activity.java:5253)
    at org.robolectric.util. ReflectionHelpers$3.run(ReflectionHelpers.java:162)
    at org.robolectric.util. ReflectionHelpers.traverseClassHierarchy(ReflectionHelpers.java:305)
    at org.robolectric.util. ReflectionHelpers.callInstanceMethod(ReflectionHelpers.java:156)
    at org.robolectric.util. ComponentController$1.run(ComponentController.java:72)
    at org.robolectric.shadows. ShadowLooper.runPaused(ShadowLooper.java:304)
    at org.robolectric.shadows. CoreShadowsAdapter$2.runPaused(CoreShadowsAdapter.java:45)
    at org.robolectric.util. ComponentController.invokeWhilePaused(ComponentController.java:69)
    at org.robolectric.util. ActivityController.start(ActivityController.java:143)
    at org.robolectric.util. ActivityController.setup(ActivityController.java:210)
    at org.robolectric. Robolectric.setupActivity(Robolectric.java:46)
    at com.company.music. MusicHomeFragmentTest.showEmptyPageWhenNoContentsAreAvailable(MusicHomeFragmentTest.java:65)
    at org.junit.runners.model. FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model. ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model. FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements. InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.powermock.modules.junit4.rule. PowerMockStatement$1.run(PowerMockRule.java:52)
    at org.powermock.reflect.internal. WhiteboxImpl.performMethodInvocation(WhiteboxImpl.java:1873)
    at org.powermock.reflect.internal. WhiteboxImpl.doInvokeMethod(WhiteboxImpl.java:773)
    at org.powermock.reflect.internal. WhiteboxImpl.invokeMethod(WhiteboxImpl.java:638)
    at org.powermock.reflect. Whitebox.invokeMethod(Whitebox.java:401)
    at org.powermock.classloading. ClassloaderExecutor.execute(ClassloaderExecutor.java:98)
    at org.powermock.classloading. ClassloaderExecutor.execute(ClassloaderExecutor.java:78)
    at org.powermock.modules.junit4.rule. PowerMockStatement.evaluate(PowerMockRule.java:49)
    at org.robolectric. RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:251)
    at org.robolectric. RobolectricTestRunner.runChild(RobolectricTestRunner.java:188)
    at org.robolectric. RobolectricTestRunner.runChild(RobolectricTestRunner.java:54)
    at org.junit.runners. ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners. ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners. ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners. ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners. ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.robolectric. RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:152)
    at org.junit.runners. ParentRunner.run(ParentRunner.java:363)
    at org.gradle.api.internal.tasks.testing.junit. JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:86)
    at org.gradle.api.internal.tasks.testing.junit. JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:49)
    at org.gradle.api.internal.tasks.testing.junit. JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:64)
    at org.gradle.api.internal.tasks.testing. SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:50)
    at org.gradle.messaging.dispatch. ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.messaging.dispatch. ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.messaging.dispatch. ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
    at org.gradle.messaging.dispatch. ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
    at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker. TestWorker.processTestClass(TestWorker.java:106)
    at org.gradle.messaging.dispatch. ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.messaging.dispatch. ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.messaging.remote.internal.hub. MessageHub$Handler.run(MessageHub.java:360)
    at org.gradle.internal.concurrent. ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
    at org.gradle.internal.concurrent. StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
    at java.util.concurrent. ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent. ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang. Thread.run(Thread.java:744)

Heres what the test looks like:
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 19)
@PowerMockIgnore({"org.mockito.*", " org.robolectric.*", " android.*"}) 
@PrepareForTest(MyThemeManager_.class)
public class MusicHomeFragmentTest {

    @Rule
    public PowerMockRule rule = new PowerMockRule();

    @Test
    public void showEmptyPageWhenNoContentsAreAvailable() {

        mockStatic(MyThemeManager_.class);

        final MyThemeManager_ themeManager = mock(MyThemeManager_.class);

        when(MyThemeManager_.getInstance_(Mockito.<Context>anyObject())).thenReturn(themeManager);

        MusicHomeActivity_ controller = Robolectric.setupActivity(MusicHomeActivity_.class);

        // TODO: Start the test. 

        PowerMockito.verifyStatic();
    }
}

build.gradle:
testCompile "junit:junit:${JUNIT_VERSION}"
testCompile "org.mockito:mockito-core:${MOCKITO_VERSION}"
testCompile "org.powermock:powermock-module-junit4:${POWERMOCK_VERSION}"
testCompile "org.powermock:powermock-module-junit4-rule:${POWERMOCK_VERSION}"
testCompile "org.powermock:powermock-api-mockito:${POWERMOCK_VERSION}"
testCompile "org.powermock:powermock-classloading-xstream:${POWERMOCK_VERSION}"

testCompile "com.jakewharton:disklrucache:${DISKLRUCACHE_VERSION}"
testCompile "org.robolectric:robolectric:${ROBOLECTRIC_VERSION}"
testCompile "org.robolectric:shadows-core:${ROBOLECTRIC_VERSION}"
testCompile "org.robolectric:shadows-support-v4:${ROBOLECTRIC_VERSION}"

ANDROID_TEST_VERSION = 0.3
DEXMAKER_VERSION = 1.4-SNAPSHOT
ESPRESSO_VERSION = 2.2
JUNIT_VERSION = 4.12
MOCKITO_VERSION = 1.10.19
POWERMOCK_VERSION = 1.6.2
ROBOLECTRIC_VERSION = 3.0
UIAUTOMATOR_VERSION = 2.1.1

How can this be resolved so that the test can execute flawlessly? 

A:

The test needs to be enhanced with an @PowerMockIgnore rule for the wrongly casted class.  It seem to have been overridden by the combination of mocking frameworks. 
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 19)
// ** CHANGE BELOW **
@PowerMockIgnore({"org.mockito.*", " org.robolectric.*", " android.*", " com.company.view. ExtRecyclerView_"})
@PrepareForTest(MyThemeManager_.class)
public class MusicHomeFragmentTest {

    @Rule
    public PowerMockRule rule = new PowerMockRule();

    @Test
    public void showEmptyPageWhenNoContentsAreAvailable() {

        mockStatic(MyThemeManager_.class);

        final MyThemeManager_ themeManager = mock(MyThemeManager_.class);

        when(MyThemeManager_.getInstance_(Mockito.<Context>anyObject())).thenReturn(themeManager);

        MusicHomeActivity_ controller = Robolectric.setupActivity(MusicHomeActivity_.class);

        // TODO: Start the test. 

        PowerMockito.verifyStatic();
    }
}

