fastlane: error running screengrab
New Issue Checklist
- Updated fastlane to the latest version
- I read the Contribution Guidelines
- I read docs.fastlane.tools
- I searched for existing GitHub issues
Issue Description
While running screengrab I am getting following error. This has been reported in the past in #9521
Error in com.package.BasicTest:
[13:28:53]: ▸ java.lang.RuntimeException: java.lang.NoSuchMethodException: getConfiguration []
[13:28:53]: ▸ at tools.fastlane.screengrab.locale.LocaleUtil.changeDeviceLocaleTo(LocaleUtil.java:46)
[13:28:53]: ▸ at tools.fastlane.screengrab.locale.LocaleTestRule$1.evaluate(LocaleTestRule.java:35)
[13:28:53]: ▸ at org.junit.rules.RunRules.evaluate(RunRules.java:20)
[13:28:53]: ▸ at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
[13:28:53]: ▸ at org.junit.runners.Suite.runChild(Suite.java:128)
[13:28:53]: ▸ at org.junit.runners.Suite.runChild(Suite.java:27)
[13:28:53]: ▸ at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
[13:28:53]: ▸ at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
[13:28:53]: ▸ at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
[13:28:53]: ▸ at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
[13:28:53]: ▸ at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
[13:28:53]: ▸ at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
[13:28:53]: ▸ at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
[13:28:53]: ▸ at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
[13:28:53]: ▸ at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
[13:28:53]: ▸ at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:384)
[13:28:53]: ▸ at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2074)
[13:28:53]: ▸ Caused by: java.lang.NoSuchMethodException: getConfiguration []
[13:28:53]: ▸ at java.lang.Class.getMethod(Class.java:2068)
[13:28:53]: ▸ at java.lang.Class.getMethod(Class.java:1690)
[13:28:53]: ▸ at tools.fastlane.screengrab.locale.LocaleUtil.changeDeviceLocaleTo(LocaleUtil.java:28)
[13:28:53]: ▸ ... 16 more
[13:28:53]: ▸ Time: 0.008
[13:28:53]: ▸ There was 1 failure:
[13:28:53]: ▸ 1) com.package.BasicTest
[13:28:53]: ▸ java.lang.RuntimeException: java.lang.NoSuchMethodException: getConfiguration []
[13:28:53]: ▸ at tools.fastlane.screengrab.locale.LocaleUtil.changeDeviceLocaleTo(LocaleUtil.java:46)
[13:28:53]: ▸ at tools.fastlane.screengrab.locale.LocaleTestRule$1.evaluate(LocaleTestRule.java:35)
[13:28:53]: ▸ at org.junit.rules.RunRules.evaluate(RunRules.java:20)
[13:28:53]: ▸ at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
[13:28:53]: ▸ at org.junit.runners.Suite.runChild(Suite.java:128)
[13:28:53]: ▸ at org.junit.runners.Suite.runChild(Suite.java:27)
[13:28:53]: ▸ at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
[13:28:53]: ▸ at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
[13:28:53]: ▸ at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
[13:28:53]: ▸ at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
[13:28:53]: ▸ at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
[13:28:53]: ▸ at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
[13:28:53]: ▸ at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
[13:28:53]: ▸ at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
[13:28:53]: ▸ at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
[13:28:53]: ▸ at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:384)
[13:28:53]: ▸ at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2074)
[13:28:53]: ▸ Caused by: java.lang.NoSuchMethodException: getConfiguration []
[13:28:53]: ▸ at java.lang.Class.getMethod(Class.java:2068)
[13:28:53]: ▸ at java.lang.Class.getMethod(Class.java:1690)
[13:28:53]: ▸ at tools.fastlane.screengrab.locale.LocaleUtil.changeDeviceLocaleTo(LocaleUtil.java:28)
[13:28:53]: ▸ ... 16 more
[13:28:53]: ▸ FAILURES!!!
[13:28:53]: ▸ Tests run: 0, Failures: 1
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (9 by maintainers)
Full explanation is here: https://developer.android.com/about/versions/pie/restrictions-non-sdk-interfaces
On Android Pie and above applications with targetSdk 28 have been restricted by Google to use reflection for accessing private api.
Screengrab is using such “dark greylisted” api to change location here: https://github.com/fastlane/fastlane/blob/f32b007ff45e648b37b6c9c2037ac481f36b7780/screengrab/screengrab-lib/src/main/java/tools.fastlane.screengrab/locale/LocaleUtil.java#L44-L46
You can see
Landroid/app/IActivityManager$Default;->updateConfiguration(Landroid/content/res/Configuration;)Zis dark greylisted indeed here: https://android.googlesource.com/platform/prebuilts/runtime/+/master/appcompat/hiddenapi-dark-greylist.txt#136Meaning screengrab becomes incompatible with androidP(28) and above for usages where locale test rule is being used.
I created https://github.com/fastlane/fastlane/issues/13679 to track and fix this @nicosommi + @hosek.
btw, which version of screengrab are you using? I hit the same issue with 1.0.0, running fine with 1.2.0