Closed sushantchoudhary closed 4 years ago
I tried removing run listener from build.gradle but it still fails with ClassNotFoundException,
2020-09-30 20:19:46.185 9252-9252/com.atlassian.android.jira.core.debug I/art: Caused by: java.lang.ClassNotFoundException: Didn't find class "org.junit.runner.notification.RunListener" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.atlassian.android.jira.core.debug.test-1/base.apk", zip file "/data/app/com.atlassian.android.jira.core.debug-2/base.apk"],nativeLibraryDirectories=[/data/app/com.atlassian.android.jira.core.debug.test-1/lib/x86, /data/app/com.atlassian.android.jira.core.debug-2/lib/x86, /system/lib, /vendor/lib]]
2020-09-30 20:19:46.185 9252-9252/com.atlassian.android.jira.core.debug I/art: at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56)
2020-09-30 20:19:46.185 9252-9252/com.atlassian.android.jira.core.debug I/art: at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:380)
2020-09-30 20:19:46.185 9252-9252/com.atlassian.android.jira.core.debug I/art: at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
2020-09-30 20:19:46.185 9252-9252/com.atlassian.android.jira.core.debug I/art: at java.lang.Object java.lang.Class.newInstance!() (Class.java:-2)
2020-09-30 20:19:46.185 9252-9252/com.atlassian.android.jira.core.debug I/art: at void android.app.ActivityThread.handleBindApplication(android.app.ActivityThread$AppBindData) (ActivityThread.java:5298)
2020-09-30 20:19:46.185 9252-9252/com.atlassian.android.jira.core.debug I/art: at void android.app.ActivityThread.-wrap2(android.app.ActivityThread, android.app.ActivityThread$AppBindData) (ActivityThread.java:-1)
2020-09-30 20:19:46.185 9252-9252/com.atlassian.android.jira.core.debug I/art: at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1528)
2020-09-30 20:19:46.185 9252-9252/com.atlassian.android.jira.core.debug I/art: at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
2020-09-30 20:19:46.185 9252-9252/com.atlassian.android.jira.core.debug I/art: at void android.os.Looper.loop() (Looper.java:154)
2020-09-30 20:19:46.185 9252-9252/com.atlassian.android.jira.core.debug I/art: at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6077)
2020-09-30 20:19:46.185 9252-9252/com.atlassian.android.jira.core.debug I/art: at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2020-09-30 20:19:46.185 9252-9252/com.atlassian.android.jira.core.debug I/art: at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:866)
2020-09-30 20:19:46.185 9252-9252/com.atlassian.android.jira.core.debug I/art: at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:756)
2020-09-30 20:19:46.186 9252-9252/com.atlassian.android.jira.core.debug I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.test.internal.runner.listener.InstrumentationResultPrinter>: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/test/internal/runner/listener/InstrumentationRunListener;
2020-09-30 20:19:46.186 9252-9252/com.atlassian.android.jira.core.debug I/art: at java.lang.Object java.lang.Class.newInstance!() (Class.java:-2)
2020-09-30 20:19:46.186 9252-9252/com.atlassian.android.jira.core.debug I/art: at void android.app.ActivityThread.handleBindApplication(android.app.ActivityThread$AppBindData) (ActivityThread.java:5298)
2020-09-30 20:19:46.186 9252-9252/com.atlassian.android.jira.core.debug I/art: at void android.app.ActivityThread.-wrap2(android.app.ActivityThread, android.app.ActivityThread$AppBindData) (ActivityThread.java:-1)
2020-09-30 20:19:46.186 9252-9252/com.atlassian.android.jira.core.debug I/art: at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1528)
2020-09-30 20:19:46.186 9252-9252/com.atlassian.android.jira.core.debug I/art: at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
2020-09-30 20:19:46.186 9252-9252/com.atlassian.android.jira.core.debug I/art: at void android.os.Looper.loop() (Looper.java:154)
2020-09-30 20:19:46.186 9252-9252/com.atlassian.android.jira.core.debug I/art: at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6077)
2020-09-30 20:19:46.186 9252-9252/com.atlassian.android.jira.core.debug I/art: at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2020-09-30 20:19:46.186 9252-9252/com.atlassian.android.jira.core.debug I/art: at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:866)
2020-09-30 20:19:46.186 9252-9252/com.atlassian.android.jira.core.debug I/art: at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:756)
It sounds like it's due to proguard. Do you proguard your test app? Try removing proguard and see if it fixes the issue.
If it still does not work, could you send us a full sample? We'll need a full sample to repro the issue. Thanks!
Thanks @adazh , removing it might not be feasible but I will the review the proguard rules in case there is way to keep these classes or not get warned. Being said, not sure how it worked for androidx test version 1.1.0
We generally do not recommend testing against proguarded apps, but yeah... you can try and see if you can keep the classes for testing.
I'll close the issue for now. Please feel free to re-open if you need further help.
Description
I updated my test library to latest stable version,
And started seeing this error in logcat,
Worked fine in older androidx test version 1.1.0
Steps to Reproduce
Create an instrumentation test to run with androidx AndroidJunitRunner
Create a Junit run listener and pass it from build.gradle e.g
testInstrumentationRunnerArgument 'listener', 'com.dummy.android.jira.core.testutil.rule. ShowToastOnRunListener'
Listener example : https://gist.github.com/sushantchoudhary/bfd06e99679f34321af83483986a7ec0
Run the test
Check for error in logcat
Expected Results
Instrumentation test should run successfully
Actual Results
Test runner errors out saying "No tests found" with error in logcat
AndroidX Test and Android OS Versions
AndroidX Test Version : 1.3.0 OS : API 28
Link to a public git repo demonstrating the problem: