appium-espresso-driver: Resources$NotFoundException Resource is not a Drawable
Appium v1.12.0 I’m not very familiar with Appium, this is my first crack at this.
I get the following exception when I try to start an Appium session with espresso. The crash is happening in the onCreate
method of all my activities (I’ve tried starting with different activities) via androidx.appcompat.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
.
This crash does not happen when I change the driver to UiAutomator2
, run the app on its own, or run my Espresso test suite. The crash only occurs when I run through Appium via the Espresso driver.
My config JSON:
{
"deviceName": "P500",
"platformName": "Android",
"platformVersion": 21,
"automationName": "Espresso",
"app": "C:\\builds\\redacted-debug.apk",
"appPackage": "com.redacted.debug",
"udid": "123456789",
"appActivity": "com.redacted.activity.SplashActivity",
"noReset": true,
"skipUnlock": true
}
Exception Stack trace:
04-26 22:29:07.231 31232 31232 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.redacted.debug/com.redacted.activity.SetupActivity}: android.content.res.Resources$NotFoundException: Resource "com.redacted.debug:dimen/cockpit_section_status_max_width" (7f070059) is not a Drawable (color or path): TypedValue{t=0x5/d=0x25801 a=2 r=0x7f070059}
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at android.app.ActivityThread.access$800(ActivityThread.java:151)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at android.os.Looper.loop(Looper.java:135)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5257)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:955)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:750)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: Caused by: android.content.res.Resources$NotFoundException: Resource "com.redacted.debug:dimen/cockpit_section_status_max_width" (7f070059) is not a Drawable (color or path): TypedValue{t=0x5/d=0x25801 a=2 r=0x7f070059}
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at android.content.res.Resources.loadDrawableForCookie(Resources.java:2441)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at android.content.res.Resources.loadDrawable(Resources.java:2381)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at android.content.res.Resources.getDrawable(Resources.java:787)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at android.content.Context.getDrawable(Context.java:403)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at androidx.core.content.ContextCompat.getDrawable(ContextCompat.java:463)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at androidx.appcompat.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:203)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at androidx.appcompat.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:191)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at androidx.appcompat.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:753)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at androidx.appcompat.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:196)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at androidx.appcompat.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:86)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at androidx.appcompat.app.AppCompatDelegateImpl.<init>(AppCompatDelegateImpl.java:260)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at androidx.appcompat.app.AppCompatDelegate.create(AppCompatDelegate.java:182)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at androidx.appcompat.app.AppCompatActivity.getDelegate(AppCompatActivity.java:520)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at androidx.appcompat.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at com.redacted.activity.SetupActivity.onCreate(SetupActivity.java:125)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:6013)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at androidx.test.runner.MonitoringInstrumentation.callActivityOnCreate(MonitoringInstrumentation.java:674)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
04-26 22:29:07.231 31232 31232 E AndroidRuntime: ... 10 more
Trying with Appium 1.13.0 gives me a different error:
[debug] [MJSONWP] Encountered internal error running command: Error: java.lang.SecurityException: Permission Denial: starting instrumentation ComponentInfo{io.appium.espressoserver.test/androidx.test.runner.AndroidJUnitRunner} from pid=13136, uid=13136 not allowed because package io.appium.espressoserver.test does not have a signature matching the target com.redacted.debug
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 9
- Comments: 62 (10 by maintainers)
I’ve managed to fix it for our app by changing this driver:
build.gradle
and server manifest to match versions in AUTespresso-contrib
(I guess these dependencies are main cause for this issue)androidx.test.espresso
group from transitive dependencies ofespresso-web
Overall I think Android build process is too complex to have espresso server setup as simple as it is now. I’d be much more confident in the server if it had most android dependencies
compileOnly
and its manifest were generated based on AUT manifest.But crash doesn’t happen when I run Espresso tests. This only happen when I run my Appium tests with Espresso driver.
It should be possible to fix this issue with
espressoBuildConfig
capability (just added PR with docs on it - https://github.com/appium/appium/pull/13766) and a config like this (if an app under test uses material components):lifecycle-extensions
line is based on fix by @uterator and perhaps it is not needed when there is no errors related to lifecycle classes.As for now, I am passing this data in a file to espressoBuildConfig capability, and it works as nothing had happened.
Two questions @TarCV ,
I found a fix for the lifecycle errors. In the
espresso-server/app/build.gradle
file, I had to add the following deps according to the docsWere you using release version for automation ? I experienced this too and had a talk with our developer and in the end we found the root cause. Try to change
proguard
rules in your local machine and build the release version APK using this configuration :I’m sure this will solve your problem … And don’t forget to push the changes to the code base 😬
Maybe we should add documentation for this too @mykola-mokhnach
@poojachoudhary13 you should replace default appium espresso server APK inside
/usr/local/lib/node_modules/appium/node_modules/appium-espresso-driver/espresso-server/app/build/outputs/apk/androidTest/debug/
with newly generated APK with changes that @TarCV mentioned above …Don’t use capability
forceEspressoRebuild
after you replace the APK …here my specific error :
Here are the dependencies which work, no Drawable or Lifecycle errors are stopping the execution anymore
Also some resource related failures may be because Espresso driver server APK doesn’t have some application dependencies. I’m implementing the related feature as part of #496 You can check if this is the case by building Espresso driver server inside
androidTest
directory of your app (i.e. by building it as if it was an Espresso test for your app). Note that you’ll need to add dependencies from https://github.com/appium/appium-espresso-driver/blob/master/espresso-server/app/build.gradle#L63-L72 (and Kotlin lines too if Kotlin is not used in your app).I can run my Espresso tests outside of Appium without issue. Is that what you mean by “rebuilding your app with Espresso”?