Skip to content Skip to sidebar Skip to footer

Robolectric 3.0 Not Working With AppCompat 21+

After upgrading to AppCompat 21, a lot of our Robolectric tests fail. It looks like there is an issue with the Toolbar and AppCompatDelegate I tried both with support-v4/appcompat

Solution 1:

I have got very similar issue and my issue was fixed after I remove "testCompile ('com.squareup:fest-android:1.0.8')" from my build.gradle.

I found this information from the Robolectric migration document and extracted below. Hope it helps.

DO NOT USE com.squareup:fest-android:1.0.8. If you have it in your testCompile be sure to remove it. There is a conflict between it and Robolectric which causes all Fragment/Activity related unit-tests to fail with NoSuchMethodError. If you have to use com.squareup:fest-android:1.0.8, then remove support-v4 from it: testCompile ('com.squareup:fest-android:1.0.8') { exclude module: 'support-v4' }


Solution 2:

This issue was caused by a library that depends on support-4v:19. Adding the following to the build file resolved the issue

    testCompile('com.example.foo') {
        exclude group: 'com.android.support', module: 'support-v4'
    }

Post a Comment for "Robolectric 3.0 Not Working With AppCompat 21+"