2

Good day! I'm trying to use AWS Device Farm for instrumented tests. But for SOME devices I got this error:

02-17 19:22:26.157 15281 15281 E AndroidRuntime: FATAL EXCEPTION: main
02-17 19:22:26.157 15281 15281 E AndroidRuntime: Process: com.mobilesense.myapplication, PID: 15281
02-17 19:22:26.157 15281 15281 E AndroidRuntime: java.lang.RuntimeException: Unable to instantiate instrumentation ComponentInfo{com.mobilesense.myapplication.test/androidx.test.runner.AndroidJUnitRunner}: java.lang.ClassNotFoundException: Didn't find class "androidx.test.runner.AndroidJUnitRunner" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib64, /vendor/lib64]]
02-17 19:22:26.157 15281 15281 E AndroidRuntime:    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5956)
02-17 19:22:26.157 15281 15281 E AndroidRuntime:    at android.app.ActivityThread.-wrap3(ActivityThread.java)
02-17 19:22:26.157 15281 15281 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1727)
02-17 19:22:26.157 15281 15281 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:102)
02-17 19:22:26.157 15281 15281 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:154)
02-17 19:22:26.157 15281 15281 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:6823)
02-17 19:22:26.157 15281 15281 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
02-17 19:22:26.157 15281 15281 E AndroidRuntime:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1557)
02-17 19:22:26.157 15281 15281 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)
02-17 19:22:26.157 15281 15281 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.test.runner.AndroidJUnitRunner" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib64, /vendor/lib64]]
02-17 19:22:26.157 15281 15281 E AndroidRuntime:    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
02-17 19:22:26.157 15281 15281 E AndroidRuntime:    at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
02-17 19:22:26.157 15281 15281 E AndroidRuntime:    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
02-17 19:22:26.157 15281 15281 E AndroidRuntime:    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5954)
02-17 19:22:26.157 15281 15281 E AndroidRuntime:    ... 8 more

My app level gradle link:

...

android {
    compileSdkVersion 30
    buildToolsVersion "29.0.3"

    defaultConfig {
        applicationId "com.signalsense.signalsenseapp"
        minSdkVersion 22
        targetSdkVersion 30
        versionCode 66
        versionName "0.60"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        testInstrumentationRunnerArguments clearPackageData: 'true'
    }

    ...

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8.toString()
    }
}

dependencies {
    ...
    //Instrumented tests
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    androidTestImplementation 'androidx.test:runner:1.3.0'
    androidTestUtil 'androidx.test:orchestrator:1.3.0'
    androidTestImplementation 'androidx.test:rules:1.3.0'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
}

Part of my test class:

@LargeTest
@RunWith(AndroidJUnit4ClassRunner::class)
class AppTest {
    @Rule
    @JvmField
    val rule = ActivityScenarioRule(SplashActivity::class.java)

    @Rule
    @JvmField
    var mGrantPermissionRule =
        GrantPermissionRule.grant(
            "android.permission.READ_PHONE_STATE",
            "android.permission.INTERNET",
            "android.permission.ACCESS_NETWORK_STATE",
            "android.permission.ACCESS_FINE_LOCATION",
            "android.permission.ACCESS_WIFI_STATE"
        )

    @Test
    fun testApp() {
     ...
    }
}

I don't understand at all why AWS Device farm even cannot to start app and fails. Some other AWS devices passes the test ok. All local devices and emulators passes this test ok too. Please help!

Vladimir Fisher
  • 3,090
  • 2
  • 17
  • 23
  • Have you been able to get some devices failing reliably while others always work? My first inclination would be to see whether or not AndroidX exists in the development environment for older devices. I’d expect AWS to provide a modern env no matter what your target, but it’s possible they push you to an old one before AndroidX existed for an old device. – Mike Collins Feb 18 '21 at 16:13
  • Hi, Mike! Do you mean that they coould not have AndroidX on some devices? Yes, I have several devices that always fails, and several devices that always success the test. But devices that fail to run the test often have a fairly high version of android, like 8. – Vladimir Fisher Feb 19 '21 at 13:15
  • Not the device, but the development environment, but I’d assume AWS uses the same one regardless of targeted device. This would be a good question for them. – Mike Collins Feb 19 '21 at 14:27

0 Answers0