0

My app recently enabled the R8. My app can run fine when R8 is enabled. The UI Test can run when R8 is disabled, but when enabled, I got the "Caused by: java.lang.ClassNotFoundException: Didn't find class "com.myapp.staff.CustomTestRunner"".

This is my build-type declaration:

buildTypes{
    ...
    create("instrumentedTest") {
        isMinifyEnabled = true
        isShrinkResources = false
        extra.apply{
            set("enableCrashlytics", false)
        }
        manifestPlaceholders["crashlyticsCollectionEnabled"] = false
        configure<CrashlyticsExtension> {
            mappingFileUploadEnabled = false
        }

        proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
        testProguardFiles("proguard-test-rules.pro")
    }
}

This is the error message:

java.lang.RuntimeException: Unable to instantiate instrumentation ComponentInfo{com.myapp.test/com.myapp.FCBTestRunner}: java.lang.ClassNotFoundException: Didn't find class "com.myapp.FCBTestRunner" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/android.test.mock.jar", zip file "/system/framework/android.test.base.jar", zip file "/data/app/~~ot6m2KJbJHL_jYouR4mQ7A==/com.myapp.test-RvSjUeMRc0WaoKaPWNYuvA==/base.apk", zip file "/data/app/~~y1oGNjg7y-o2Lyq2z1RnqA==/com.myapp-gxOR-I3OFZEffP9SJyjDEg==/base.apk"],nativeLibraryDirectories=[/system/lib64, /system/system_ext/lib64, /system/product/lib64]]
  • I've check the generated mapping file, the CustomTestRunner is not obfuscased.

# {"id":"sourceFile","fileName":"FCBTestRunner.kt"}
    0:0:void <clinit>() -> <clinit>
    8:8:void <init>() -> <init>
    14:14:android.app.Application newApplication(java.lang.ClassLoader,java.lang.String,android.content.Context) -> newApplication
  • I've check the androidTest.apk by using Android Studio APK Analyzer. The CustomTestRunner is exists inside the com/myapp/staff

  • I've tried disable the obfuscase to the testProguardFiles by -dontobfuscate.

  • Change the testProguardFiles:

    testProguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro", "proguard-test-rules.pro")
    
2
  • This looks like the known issue issuetracker.google.com/126429384. Can you please check that? Commented Jun 17, 2024 at 11:03
  • I added the Keeper plugin and still got the error. Commented Jun 18, 2024 at 6:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.