개발/Android Studio 에러

에러: Didn't find class "androidx.test.runner.AndroidJUnitRunner" on

스몰스테핑 2024. 5. 23. 18:32

다음과 같은 에러가 발생하였다.

 

java.lang.RuntimeException: Unable to instantiate instrumentation ComponentInfo{xxx.yyy.test/android.support.test.runner.AndroidJUnitRunner}: java.lang.ClassNotFoundException: Didn't find class "android.support.test.runner.AndroidJUnitRunner" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib, /vendor/lib]]
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5730)
        at android.app.ActivityThread.-wrap1(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6541)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.test.runner.AndroidJUnitRunner" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib, /vendor/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5728)
        at android.app.ActivityThread.-wrap1(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661) 
        at android.os.Handler.dispatchMessage(Handler.java:105) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6541) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

 

https://stackoverflow.com/questions/52717048/didnt-find-class-android-support-test-runner-androidjunitrunner

 

Didn't find class "android.support.test.runner.AndroidJUnitRunner"

I'm trying to use an instrumented test and I updated my project to AndroidX. But I get the following error while trying to run: 2018-10-09 14:22:29.468 13263-13263/xxx.yyy E/AndroidRuntime: FATAL

stackoverflow.com

 

build.gradle (Module: app)에서 testInstrumentationRunner 부분을 수정하라는 부분이 있었으나, 해당 질문이 오래되었기 때문에 안드로이드 -> 안드로이드X로 버전 업하면서 있었던 문제라 이는 필자에게 해당되지 않았다.

 

 

 

다음 답변이 내 문제를 해결시켜주었는데, 종속성 추가를 잊었을 경우 동일한 문제가 발생했고, 종속성에 다음을 추가하라는 것이었다.

androidTestImplementation("androidx.test:runner:${currentVersion}")

 

 

24년 5월 23일 기준 runner 버전은 1.5.2였다.

androidTestImplementation("androidx.test:runner:1.5.2")

 

 

종속성 추가후, 테스트 통과