Am working on an SDK and its test failed with the following error. But still I can able to build assemble and the aar is working flawlessly. But when i run the test am getting the following error..

at androidx.lifecycle.ViewTreeLifecycleOwner.set(ViewTreeLifecycleOwner.java:49)
at androidx.activity.ComponentActivity.initViewTreeOwners(ComponentActivity.java:431)
at androidx.activity.ComponentActivity.setContentView(ComponentActivity.java:402)
at com.demo.app.application.MainActivityFragment.onCreate(MainActivityFragment.java:20)
at android.app.Activity.performCreate(Activity.java:7802)
at android.app.Activity.performCreate(Activity.java:7791)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
at androidx.test.runner.MonitoringInstrumentation.callActivityOnCreate(MonitoringInstrumentation.java:730)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.lifecycle.runtime.R$id" on path: DexPathList[[zip file "/data/app/com.app.demo.test-j1kivHfi4LEQWZGW5bU8sw==/base.apk"],nativeLibraryDirectories=[/data/app/com.app.demo.test-j1kivHfi4LEQWZGW5bU8sw==/lib/x86, /system/fake-libs, /data/app/com.app.demo.test-j1kivHfi4LEQWZGW5bU8sw==/base.apk!/lib/x86, /system/lib, /system/product/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 20 more```



in addition, in my log i can see the error 


 ``` java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/lifecycle/runtime/R$id;
        at androidx.lifecycle.ViewTreeLifecycleOwner.set(ViewTreeLifecycleOwner.java:49)
Tests on Pixel_XL_API_30(AVD) - 11 failed: Instrumentation run failed due to 'Process crashed.'```
0

There are 0 best solutions below