Run Android test with Robolectric - dependency error

前端 未结 2 1945
再見小時候
再見小時候 2021-01-12 16:44

I am using Android Studio 1.2 and Windows 7

When running a robolectric test following this example:

@RunWith(CustomRobolectricRunner.class)
@Config(e         


        
2条回答
  •  [愿得一人]
    2021-01-12 17:16

    I've been able to fix the same issue by overriding Robolectric Maven repository URL.

    Sonatype is not available for some reason and Maven Central moved to HTTPS starting from Jan 15, 2020. So, I've decided to use Maven Central URL but with a secure scheme.

    Editing the system property which is used by Robolectric RoboSettings class allowed me to use a different URL.

    android {
        testOptions {
            unitTests.all {
                systemProperty 'robolectric.dependency.repo.url', 'https://repo1.maven.org/maven2'
            }
        }
    }
    

提交回复
热议问题