Skip to content
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

Closed
zpiao1 opened this issue Feb 22, 2022 · 10 comments

Comments

@zpiao1
Copy link

zpiao1 commented Feb 22, 2022

Hi, I find another issue with Compose support from espresso driver. When the Composable contains a TextField, espresso server fails to start, with the Resource$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.

package dev.chiukingyee.androidapp

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.material.TextField
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        Log.i(
            "MainActivity",
            "id=0x${androidx.compose.ui.R.string.default_error_message.toString(16)}"
        )
        setContent {
            var textFieldValue by remember { mutableStateOf("") }
            TextField(
                value = textFieldValue,
                onValueChange = { textFieldValue = it },
                modifier = Modifier.testTag("textField")
            )
        }
    }
}

Full Stacktrace

2022-02-22 20:53:16.943 11568-11568/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: dev.chiukingyee.androidapp, PID: 11568
    android.content.res.Resources$NotFoundException: String resource ID #0x7f080003
        at android.content.res.Resources.getText(Resources.java:444)
        at android.content.res.Resources.getString(Resources.java:537)
        at androidx.compose.material.Strings_androidKt.getString-4foXLRw(Strings.android.kt:32)
        at androidx.compose.material.TextFieldImplKt$TextFieldImpl$1.invoke-rAjV9yQ(TextFieldImpl.kt:140)
        at androidx.compose.material.TextFieldImplKt$TextFieldImpl$1.invoke(TextFieldImpl.kt:99)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:149)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
        at androidx.compose.material.TextFieldTransitionScope.Transition(TextFieldImpl.kt:299)
        at androidx.compose.material.TextFieldImplKt.TextFieldImpl(TextFieldImpl.kt:97)
        at androidx.compose.material.TextFieldKt.TextField(TextField.kt:296)
        at androidx.compose.material.TextFieldKt.TextField(TextField.kt:181)
        at dev.chiukingyee.androidapp.MainActivity$onCreate$1$1$1.invoke(MainActivity.kt:29)
        at dev.chiukingyee.androidapp.MainActivity$onCreate$1$1$1.invoke(MainActivity.kt:27)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
        at androidx.compose.material.SurfaceKt$Surface$6.invoke(Surface.kt:267)
        at androidx.compose.material.SurfaceKt$Surface$6.invoke(Surface.kt:254)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
        at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:215)
        at androidx.compose.material.SurfaceKt.Surface-F-jzlyU(Surface.kt:251)
        at androidx.compose.material.SurfaceKt.Surface-F-jzlyU(Surface.kt:110)
        at dev.chiukingyee.androidapp.MainActivity$onCreate$1$1.invoke(MainActivity.kt:24)
        at dev.chiukingyee.androidapp.MainActivity$onCreate$1$1.invoke(MainActivity.kt:22)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
        at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:215)
        at androidx.compose.material.TextKt.ProvideTextStyle(Text.kt:252)
        at androidx.compose.material.MaterialThemeKt$MaterialTheme$1.invoke(MaterialTheme.kt:81)
        at androidx.compose.material.MaterialThemeKt$MaterialTheme$1.invoke(MaterialTheme.kt:80)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
        at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:215)
        at androidx.compose.material.MaterialThemeKt.MaterialTheme(MaterialTheme.kt:72)
        at dev.chiukingyee.androidapp.ui.theme.ThemeKt.AndroidAppTheme(Theme.kt:38)
        at dev.chiukingyee.androidapp.MainActivity$onCreate$1.invoke(MainActivity.kt:22)
        at dev.chiukingyee.androidapp.MainActivity$onCreate$1.invoke(MainActivity.kt:21)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
        at androidx.compose.ui.platform.ComposeView.Content(ComposeView.android.kt:384)
        at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:228)
        at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:227)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
2022-02-22 20:53:16.944 11568-11568/? E/AndroidRuntime:     at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:215)
        at androidx.compose.ui.platform.CompositionLocalsKt.ProvideCommonCompositionLocals(CompositionLocals.kt:148)
        at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:114)
        at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:113)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
        at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:215)
        at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt.ProvideAndroidCompositionLocals(AndroidCompositionLocals.android.kt:106)
        at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$3.invoke(Wrapper.android.kt:162)
        at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$3.invoke(Wrapper.android.kt:161)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
        at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:215)
        at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:161)
        at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:144)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
        at androidx.compose.runtime.ComposerKt.invokeComposable(Composer.kt:3330)
        at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:2577)
        at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:2573)
        at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(SnapshotState.kt:540)
        at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:2566)
        at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:2517)
        at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:476)
        at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:727)
        at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:432)
        at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:144)
        at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:135)
        at androidx.compose.ui.platform.AndroidComposeView.setOnViewTreeOwnersAvailable(AndroidComposeView.android.kt:727)
        at androidx.compose.ui.platform.WrappedComposition.setContent(Wrapper.android.kt:135)
        at androidx.compose.ui.platform.WrappedComposition.onStateChanged(Wrapper.android.kt:187)
        at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:354)
        at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.java:196)
        at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:142)
        at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:135)
        at androidx.compose.ui.platform.AndroidComposeView.onAttachedToWindow(AndroidComposeView.android.kt:814)
        at android.view.View.dispatchAttachedToWindow(View.java:20753)
        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3490)
        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2613)

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 string androidx.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:

  1. Logging the value of androidx.compose.ui.R.string.default_error_message in the androidTest code of the espresso driver, the result is 0x7f080003
  2. Logging the value of androidx.compose.ui.R.string.default_error_message in the test app, the result is 7f0a0004 (Can be other values, but different from the value in 1)
  3. In the exception where androidx.compose.ui.R.string.default_error_message is reference from Compose Material itself, the ID is also 0x7f080003, 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.

@@ -129,4 +129,7 @@
-    androidTestImplementation("androidx.compose.ui:ui-test:${Version.compose}")
-    androidTestImplementation("androidx.compose.ui:ui-test-junit4:${Version.compose}"){
-        isTransitive = false
-    }

+    androidTestImplementation("androidx.compose.ui:ui-test:${Version.compose}") {
+        exclude(group = "androidx.compose.ui", module = "ui")
+    }
+    androidTestImplementation("androidx.compose.ui:ui-test-junit4:${Version.compose}") {
+        exclude(group = "androidx.compose.ui", module = "ui")
+    }
+    androidTestCompileOnly("androidx.compose.ui:ui:${Version.compose}")

This excludes androidx.compose.ui:ui from the APK that contains the espresso server. Thus, so long as the test app has implementation("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.

@rajdeepv
Copy link
Collaborator

Hi, @zpiao1 I guess this is a good idea to create a PR with above changes

@zpiao1
Copy link
Author

zpiao1 commented Feb 23, 2022

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 (androidx.compose.ui.R.string) only instead of removing the whole dependency of androidx.compose.ui:ui

@rajdeepv
Copy link
Collaborator

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 espressoBuildConfig capability

@zpiao1
Copy link
Author

zpiao1 commented Feb 24, 2022

I've tried to use the same version of androidx.compose.ui:ui for both app under test and the espresso server.
The default version in espresso server is 1.0.5 so I changed my app's androidx.compose.ui:ui to 1.0.5.
I've also tried to use espressoBuildConfig like this in the appium client:

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.
Both result in the same Exception when there is a TextField Composable

@rajdeepv
Copy link
Collaborator

can you please set capability forceEspressoRebuild: true to make sure a new server was built?
Also, does changing compose version to 1.1.0 directly in the espresso code fix your issue?

@zpiao1
Copy link
Author

zpiao1 commented Feb 24, 2022

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 appium/node_modules to change the compose version in the Version object. However, the result is still the same with the same Exception. After failing, I go and check the temp folder that builds the espresso server and verified that the compose version there is updated.

@zpiao1
Copy link
Author

zpiao1 commented Feb 24, 2022

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 (androidx.compose.ui.R$string.default_error_message) actually has different value

This is the screenshot of the espresso server APK:
image

This is the screenshot of the AUT APK:
image

@rajdeepv
Copy link
Collaborator

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 espressoBuildConfig capability

  espressoBuildConfig: '{"additionalAndroidTestDependencies": ' +
  '["androidx.lifecycle:lifecycle-extensions:2.2.0", ' +
  '"androidx.activity:activity:1.3.1", ' +
  '"androidx.fragment:fragment:1.3.4"]}'

@zpiao1
Copy link
Author

zpiao1 commented Feb 24, 2022

Oh I tried adding your espressoBuildConfig capability and it worked!
In fact, it's the fragment dependency that made it work.
Here is my full espressoBuildConfig:

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.
Here is output after running ./gradlew app:androidDependencies in the temporary folder that is used to build the Espresso server, after applying all the changes above (SDK, Kotlin version, etc.)

Espresso Server debugAndroidTestRuntimeClasspath
debugAndroidTestRuntimeClasspath - Dependencies for runtime/packaging
+--- androidx.test.espresso:espresso-web:3.4.0@aar
+--- androidx.compose.ui:ui-test-junit4:1.1.1@aar
+--- androidx.test.ext:junit:1.1.2@aar
+--- androidx.test:core:1.4.0@aar
+--- androidx.test:rules:1.4.0@aar
+--- androidx.compose.ui:ui-test:1.1.1@aar
+--- androidx.test.espresso:espresso-core:3.4.0@aar
+--- androidx.test:runner:1.4.0@aar
+--- androidx.fragment:fragment:1.4.1@aar
+--- androidx.test.services:storage:1.4.0@aar
+--- androidx.test:monitor:1.5.0@aar
+--- androidx.activity:activity-compose:1.3.0@aar
+--- androidx.compose.ui:ui:1.1.1@aar
+--- androidx.compose.ui:ui-text:1.1.1@aar
+--- androidx.compose.ui:ui-graphics:1.1.1@aar
+--- androidx.compose.ui:ui-unit:1.1.1@aar
+--- androidx.compose.runtime:runtime-saveable:1.1.1@aar
+--- androidx.compose.ui:ui-geometry:1.1.1@aar
+--- androidx.compose.runtime:runtime:1.1.1@aar
+--- androidx.activity:activity-ktx:1.3.0@aar
+--- androidx.core:core-ktx:1.2.0@aar
+--- androidx.viewpager:viewpager:1.0.0@aar
+--- androidx.loader:loader:1.0.0@aar
+--- androidx.autofill:autofill:1.0.0@aar
+--- androidx.customview:customview:1.0.0@aar
+--- androidx.activity:activity:1.3.0@aar
+--- androidx.core:core:1.5.0@aar
+--- androidx.core:core:1.5.0@aar
+--- androidx.versionedparcelable:versionedparcelable:1.1.1@aar
+--- androidx.collection:collection:1.1.0@jar
+--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.3.1@aar
+--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1@aar
+--- androidx.lifecycle:lifecycle-viewmodel:2.3.1@aar
+--- androidx.lifecycle:lifecycle-viewmodel:2.3.1@aar
+--- androidx.savedstate:savedstate-ktx:1.1.0@aar
+--- androidx.savedstate:savedstate:1.1.0@aar
+--- androidx.test:annotation:1.0.0@aar
+--- androidx.lifecycle:lifecycle-common-java8:2.3.0@jar
+--- androidx.profileinstaller:profileinstaller:1.1.0@aar
+--- androidx.lifecycle:lifecycle-livedata:2.0.0@aar
+--- androidx.lifecycle:lifecycle-livedata-core:2.3.1@aar
+--- androidx.lifecycle:lifecycle-livedata-core:2.3.1@aar
+--- androidx.lifecycle:lifecycle-runtime-ktx:2.3.1@aar
+--- androidx.lifecycle:lifecycle-runtime:2.3.1@aar
+--- androidx.arch.core:core-runtime:2.1.0@aar
+--- androidx.arch.core:core-common:2.1.0@jar
+--- androidx.lifecycle:lifecycle-common:2.3.1@jar
+--- androidx.startup:startup-runtime:1.0.0@aar
+--- androidx.tracing:tracing:1.0.0@aar
+--- androidx.annotation:annotation:1.3.0@jar
+--- androidx.test.espresso:espresso-contrib:3.4.0@aar
+--- androidx.test.uiautomator:uiautomator:2.2.0@aar
+--- com.google.code.gson:gson:2.8.9@jar
+--- org.nanohttpd:nanohttpd-webserver:2.3.1@jar
+--- org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.2@jar
+--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2@jar
+--- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.2@jar
+--- org.jetbrains.kotlinx:kotlinx-coroutines-debug:1.5.2@jar
+--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30@jar
+--- org.jetbrains.kotlin:kotlin-reflect:1.5.10@jar
+--- org.ccil.cowan.tagsoup:tagsoup:1.2@jar
+--- junit:junit:4.12@jar
+--- org.nanohttpd:nanohttpd:2.3.1@jar
+--- androidx.compose.ui:ui-util:1.1.1@aar
+--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.30@jar
+--- org.jetbrains.kotlin:kotlin-stdlib:1.6.10@jar
+--- org.jetbrains.kotlin:kotlin-stdlib-common:1.6.10@jar
+--- androidx.test.espresso:espresso-idling-resource:3.4.0@aar
+--- androidx.annotation:annotation-experimental:1.1.0@aar
+--- com.squareup:javawriter:2.1.1@jar
+--- javax.inject:javax.inject:1@jar
+--- org.hamcrest:hamcrest-integration:1.3@jar
+--- org.hamcrest:hamcrest-library:1.3@jar
+--- com.google.code.findbugs:jsr305:2.0.1@jar
+--- org.hamcrest:hamcrest-core:1.3@jar
+--- org.jetbrains:annotations:13.0@jar
+--- net.java.dev.jna:jna-platform:5.5.0@jar
\--- net.java.dev.jna:jna:5.5.0@jar

And here is the output of ./gradlew app:assembleDebug running in the project that builds the AUT

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 androidx.fragment:fragment in the AUT, so I guess it's what androidx.fragment:fragment depends that took effect.
The problem is if there is a way to determine what are the necessary additionalAndroidTestDependencies instead of guessing one by one?

@rajdeepv
Copy link
Collaborator

androidx.fragment:fragment could be a transitive dependency of one of your app modules. It's tough to say without looking at actual code. But for most cases, below should work in similar case (versions of dependencies matching with the app under test)

try with below espressoBuildConfig capability

  espressoBuildConfig: '{"additionalAndroidTestDependencies": ' +
  '["androidx.lifecycle:lifecycle-extensions:2.2.0", ' +
  '"androidx.activity:activity:1.3.1", ' +
  '"androidx.fragment:fragment:1.3.4"]}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants