robolectric / robolectric

Android Unit Testing Framework
http://robolectric.org
Other
5.89k stars 1.37k forks source link

error: cannot access TextRunShaper #9683

Open icegood opened 5 days ago

icegood commented 5 days ago

Description

error: cannot access TextRunShaper ShadowApplication app = Shadows.shadowOf(mTestContext); ^ class file for android.graphics.text.TextRunShaper not found 1 error

FAILURE: Build failed with an exception.

Steps to Reproduce

Call:

mTestContext = RuntimeEnvironment.getApplication(); ShadowApplication app = Shadows.shadowOf(mTestContext);

Robolectric & Android Version

testImplementation 'org.robolectric:robolectric:4.12'

compileSdk 33
    minSdkVersion 30
    targetSdkVersion 30

Link to a public git repo demonstrating the problem:

none

icegood commented 5 days ago

in my tests: @RunWith(RobolectricTestRunner.class) @Config(sdk = 30)

while https://developer.android.com/reference/android/graphics/text/TextRunShaper is from API 31.

Why API 31 is brought up?

utzcoz commented 4 days ago

@icegood What about trying 4.13? It fixed some compatibility issues like TextRunShaper that you used. https://github.com/robolectric/robolectric/pull/9033.

utzcoz commented 2 days ago

I tested it with https://github.com/robolectric/robolectric/pull/9687, and your sample code works without any error in sdkcompat integration test module. So I think it can work with Robolectric 4.13.