-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resource$NotFoundException: String resource ID issue when test app has TextField Composable #755
Comments
Hi, @zpiao1 I guess this is a good idea to create a PR with above changes |
Yes I was considering creating a PR. But just now I did some more testing and realized that if the test app does not have any compose dependency the espresso server will also crash (which is common if the test app only has views but not compose). I guess we might need a better way to remove the duplicated class ( |
Most probably synchronizing the versions between your app under test and the espresso server will make it work. you can customize which version to use in espresso using |
I've tried to use the same version of caps['appium:espressoBuildConfig'] = json.dumps({
'toolsVersions': {
'gradle': 7.4,
'androidGradlePlugin': '7.1.1',
'compileSdk': 31,
'buildTools': '31.0.0',
'targetSdk': 31,
'kotlin': '1.6.10',
},
'additionalAndroidTestDependencies': [
'androidx.compose.ui:ui-test:1.1.0',
'androidx.compose.ui:ui-test-junit4:1.1.0',
]
}) with the app under test using Compose 1.1.0. |
can you please set capability forceEspressoRebuild: true to make sure a new server was built? |
I've enabled forceEspressoRebuild together with other options caps['appium:forceEspressoRebuild'] = True
caps['appium:showGradleLog'] = True
caps['appium:enforceAppInstall'] = True and from appium logs I do see the Gradle is running every time I start the tests I also tried to go to the appium-espresso-driver directory in |
I also tried to inspect the APKs of both the espresso server (in the temp folder that is to be installed on device), and the AUT. And I found that the same field of the same class ( |
When I had similar issue, I had to see Gradle dependencies graph to match exact version of dependencies. For eg, you can try with below
|
Oh I tried adding your caps['appium:espressoBuildConfig'] = json.dumps({
'toolsVersions': {
'gradle': 7.4,
'androidGradlePlugin': '7.1.2',
'compileSdk': 31,
'buildTools': '31.0.0',
'targetSdk': 31,
'kotlin': '1.6.10',
},
'additionalAndroidTestDependencies': [
'androidx.compose.ui:ui-test:1.1.1',
'androidx.compose.ui:ui-test-junit4:1.1.1',
'androidx.fragment:fragment:1.3.4', # I also tried 1.4.1 and it also worked
]
}) I have no idea of how it worked and I tried to print the gradle dependencies. Espresso Server debugAndroidTestRuntimeClasspath
And here is the output of AUT debugRuntimeClasspath``` debugRuntimeClasspath - Dependencies for runtime/packaging +--- androidx.compose.ui:ui-tooling:1.1.1@aar +--- androidx.compose.material:material:1.1.1@aar +--- androidx.activity:activity-compose:1.4.0@aar +--- androidx.compose.ui:ui-tooling-data:1.1.1@aar +--- androidx.compose.material:material-ripple:1.1.1@aar +--- androidx.compose.foundation:foundation:1.1.1@aar +--- androidx.compose.animation:animation:1.1.1@aar +--- androidx.compose.material:material-icons-core:1.1.1@aar +--- androidx.compose.foundation:foundation-layout:1.1.1@aar +--- androidx.compose.animation:animation-core:1.1.1@aar +--- androidx.compose.ui:ui:1.1.1@aar +--- androidx.activity:activity-ktx:1.4.0@aar +--- androidx.lifecycle:lifecycle-runtime-ktx:2.4.1@aar +--- androidx.compose.ui:ui-tooling-preview:1.1.1@aar +--- androidx.compose.ui:ui-text:1.1.1@aar +--- androidx.compose.runtime:runtime-saveable:1.1.1@aar +--- androidx.compose.ui:ui-graphics:1.1.1@aar +--- androidx.compose.ui:ui-unit:1.1.1@aar +--- androidx.compose.ui:ui-geometry:1.1.1@aar +--- androidx.compose.runtime:runtime:1.1.1@aar +--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1@aar +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2@jar +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.2@jar +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10@jar +--- androidx.core:core-ktx:1.7.0@aar +--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10@jar +--- androidx.compose.ui:ui-util:1.1.1@aar +--- androidx.activity:activity:1.4.0@aar +--- androidx.savedstate:savedstate-ktx:1.1.0@aar +--- org.jetbrains.kotlin:kotlin-stdlib:1.6.10@jar +--- androidx.autofill:autofill:1.0.0@aar +--- androidx.core:core:1.7.0@aar +--- androidx.core:core:1.7.0@aar +--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.3.1@aar +--- androidx.savedstate:savedstate:1.1.0@aar +--- androidx.profileinstaller:profileinstaller:1.1.0@aar +--- androidx.lifecycle:lifecycle-runtime:2.4.1@aar +--- androidx.versionedparcelable:versionedparcelable:1.1.1@aar +--- androidx.concurrent:concurrent-futures:1.0.0@jar +--- androidx.collection:collection:1.1.0@jar +--- androidx.startup:startup-runtime:1.0.0@aar +--- androidx.lifecycle:lifecycle-common-java8:2.4.1@jar +--- androidx.lifecycle:lifecycle-livedata-core:2.3.1@aar +--- androidx.lifecycle:lifecycle-common:2.4.1@jar +--- androidx.arch.core:core-runtime:2.1.0@aar +--- androidx.arch.core:core-common:2.1.0@jar +--- androidx.tracing:tracing:1.0.0@aar +--- androidx.lifecycle:lifecycle-viewmodel:2.3.1@aar +--- androidx.annotation:annotation:1.2.0@jar +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.6.10@jar +--- org.jetbrains:annotations:13.0@jar +--- androidx.annotation:annotation-experimental:1.1.0@aar \--- com.google.guava:listenablefuture:1.0@jar ```There is actually no dependency on |
|
Hi, I find another issue with Compose support from espresso driver. When the Composable contains a
TextField
, espresso server fails to start, with theResource$NotFoundException
. However, opening the app from launcher doesn't crash.Reproducing
Just a minimal example Composable that contains a TextField will cause the error.
This issue happens both when using Compose 1.0.X or 1.1.0.
Full Stacktrace
Possible Reason
It took me a long time to find out what's causing the issue. From the stacktrace, the
TextFieldImpl
is trying to get a resource string as the default error message (Source), which in turn gets the resource stringandroidx.compose.ui.R.string.default_error_message
(Source).However, the value of this resource is different depending on where we call it. (I have no idea why)
I've tested the below cases:
androidx.compose.ui.R.string.default_error_message
in the androidTest code of the espresso driver, the result is0x7f080003
androidx.compose.ui.R.string.default_error_message
in the test app, the result is7f0a0004
(Can be other values, but different from the value in 1)androidx.compose.ui.R.string.default_error_message
is reference from Compose Material itself, the ID is also0x7f080003
, same as in 1.Workaround
I also checked the other issue #449 and think whether it's the same issue. The fixes in that issue kind of inspired me that it might be because both the espresso server APK and the test app's APK contain the same class
androidx.compose.ui.R.string
therefore in runtime there is some conflicts.After experimenting, changing the dependencies in app module's build.gradle.kts like this can fix the issue.
This excludes
androidx.compose.ui:ui
from the APK that contains the espresso server. Thus, so long as the test app hasimplementation("androidx.compose.ui:ui:${Version.compose}")
, the classes used eventually are from the test app instead of from the espresso server.After rebuilding the espresso server, the test can start successfully.
The text was updated successfully, but these errors were encountered: