Detox: getAttributes() does not work in detox 18.14.0 in Android

Describe the bug

The getAttributes() function does not work in Android with Detox 18.14.0.

It throws an error : java.lang.ClassNotFoundException: com.google.android.material.slider.Slider

Steps To Reproduce

  • I have tested this issue on the latest Detox release (18.17.0) and it still reproduces
  1. Issue appeared in detox version 18.14.0 . Release note fo this version mentions that the getAttributes() function works in Android.
  2. Issue does not appear in iOS.

Expected behavior

Detox Trace-Logs

N/A

Device logs (adb logcat)

06-18 09:40:11.001  9652  9773 D DetoxWSClient: Received action 'invoke' (ID #33, params={"target":{"type":"Class","value":"com.wix.detox.espresso.EspressoDetox"},"method":"perform","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"androidx.test.espresso.Espresso"},"method":"onView","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForTestId","args":["homeScreen_stars_counter_value"]}}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxAction"},"method":"getAttributes","args":[]}}]})
06-18 09:40:11.001  9652  9771 I DetoxDispatcher: Handling action 'invoke' (ID #33)...
06-18 09:40:11.002  9652  9771 D Detox   : class com.wix.detox.espresso.DetoxMatcher, matcherForTestId, [homeScreen_stars_counter_value]
06-18 09:40:11.004  9652  9771 D Detox   : class androidx.test.espresso.Espresso, onView, [(with tag value: is "homeScreen_stars_counter_value" and view has effective visibility=VISIBLE)]
06-18 09:40:11.004  9652  9771 D Detox   : class com.wix.detox.espresso.DetoxAction, getAttributes, []
06-18 09:40:11.007  9652  9771 D Detox   : class com.wix.detox.espresso.EspressoDetox, perform, [androidx.test.espresso.ViewInteraction@4ba662b, com.wix.detox.espresso.action.GetAttributesAction@ec0ca88]
06-18 09:40:11.013  9652  9652 D IdlingResourceRegistry: All idling resources are idle.
06-18 09:40:11.015  9652  9652 D IdlingResourceRegistry: All idling resources are idle.
06-18 09:40:11.016  9652  9652 I ViewInteraction: Performing 'Get view attributes' action on view (with tag value: is "homeScreen_stars_counter_value" and view has effective visibility=VISIBLE)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: Test exception
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: java.lang.reflect.InvocationTargetException
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at java.lang.reflect.Method.invoke(Native Method)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at org.apache.commons.lang3.reflect.MethodUtils.invokeStaticMethod(MethodUtils.java:443)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at org.apache.commons.lang3.reflect.MethodUtils.invokeStaticMethod(MethodUtils.java:405)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at com.wix.invoke.types.ClassTarget.execute(ClassTarget.java:23)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at com.wix.invoke.types.Target.invoke(Target.java:59)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at com.wix.invoke.MethodInvocation.invoke(MethodInvocation.java:35)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at com.wix.invoke.MethodInvocation.invoke(MethodInvocation.java:26)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at com.wix.invoke.MethodInvocation.invoke(MethodInvocation.java:20)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at com.wix.detox.adapters.server.InvokeActionHandler.handle(DetoxActionHandlers.kt:56)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at com.wix.detox.adapters.server.ActionsExecutor$executeAction$$inlined$let$lambda$1.run(DetoxActionsDispatcher.kt:64)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at android.os.Handler.handleCallback(Handler.java:883)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at android.os.Handler.dispatchMessage(Handler.java:100)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at android.os.Looper.loop(Looper.java:214)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at com.wix.detox.adapters.server.ActionsExecutor$1.run(DetoxActionsDispatcher.kt:50)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at java.lang.Thread.run(Thread.java:919)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/material/slider/Slider;
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at com.wix.detox.espresso.action.SliderAttributes.get(GetAttributesAction.kt:143)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at com.wix.detox.espresso.action.GetAttributesAction.perform(GetAttributesAction.kt:35)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at androidx.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:16)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at androidx.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:65)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at androidx.test.espresso.ViewInteraction.access$100(ViewInteraction.java:15)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java:3)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java:2)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at android.os.Handler.handleCallback(Handler.java:883)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at android.os.Handler.dispatchMessage(Handler.java:100)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at android.os.Looper.loop(Looper.java:214)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at android.app.ActivityThread.main(ActivityThread.java:7356)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at java.lang.reflect.Method.invoke(Native Method)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: Caused by: java.lang.ClassNotFoundException: com.google.android.material.slider.Slider
06-18 09:40:11.017  9652  9771 I DetoxActionHandlers: 	... 15 more
06-18 09:40:11.017  9652  9771 I DetoxWSClient: Sending out action 'testFailed' (ID #33)
06-18 09:40:11.017  9652  9771 I DetoxDispatcher: Done with action 'invoke'
06-18 09:40:11.055  1813  2087 E SurfaceFlinger: ro.sf.lcd_density must be defined as a build property
06-18 09:40:11.144  1813  2087 E SurfaceFlinger: ro.sf.lcd_density must be defined as a build property
06-18 09:40:11.161  9810  9810 D MPEG4Writer: Video track stopping. Stop source
06-18 09:40:11.161  9810  9810 D MPEG4Writer: Video track source stopping

Screenshots

Screen Shot 2021-06-18 at 8 30 44 AM

Environment (please complete the following information):

  • Detox: 18.14.0
  • React Native: 0.63.4
  • Node: 14.15.0
  • Device: Google Pixel XL API 29
  • OS: Android
  • Test-runner : jest

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 6
  • Comments: 27 (1 by maintainers)

Most upvoted comments

I am facing the same building issue, but only in release builds. Adding implementation 'com.google.android.material:material:1.2.1' did the trick for me for now.

Theoretically, this shouldn’t be defined explicitly by anyone. I’m surprised as you are - that this fails on anyone’s build.

Try, instead:

implementation 'com.google.android.material:material:1.3.0'

<ImageBackground style={styles.icon} source={this.props.icon}>
            <Text
              testID={this.props.testID + "_counter_value"}
              style={[styles.value, valueFontSize]}
            >
              {this.props.value}
            </Text>
            <Text style={[sharedStyle.textStyle.small2, styles.title]}>
              {this.props.title}
            </Text>
          </ImageBackground>

No it’s not stale I am still getting this issue on detox 19 and react native 0.66

Although this fixes the issue, but it should be fixed by library itself

I am facing the same building issue, but only in release builds. Adding implementation ‘com.google.android.material:material:1.2.1’ did the trick for me for now.

@d4vidi I’m hitting this on Detox 19.12.5

@AshrafRizvi01 @tran2 please try using Detox 19.12.5 (or newer); Be sure to remove any custom proguard rules before you do.

Tested with both methods, neither did work. However this worked: dependencies { // … implementation ‘com.google.android.material:material:1.2.0-rc01’ }