Matthis.h
Matthis.h

Reputation: 909

Unable to find instrumentation info for androidx.test.runner.AndroidJUnitRunner

I want use fastlane screengrab and when I lauch fastlane screengrab I have this error : android.util.AndroidException: INSTRUMENTATION_FAILED: my.package/androidx.test.runner.AndroidJUnitRunner

I found my.package with command -> adb shell "pm list packages"|cut -f 2 -d ":"

But when I launch adb shell pm list instrumentation I have this result -> instrumentation:org.chromium.webview_shell/.WebViewLayoutTestRunner (target=org.chromium.webview_shell). I haven't androidX.TestRunner

I declared testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" in my build.gradle

AndroidManifest.xml

<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="my.package"
>

<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- Allows unlocking your device and activating its screen so UI tests can succeed -->
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>

<!-- Allows for storing and retrieving screenshots -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<!-- Allows changing locales -->
<permission android:name="android.permission.CHANGE_CONFIGURATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
    android:name="name"
    android:allowBackup="false"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="false"
    android:usesCleartextTraffic="true"
    android:theme="@style/theme"
    tools:replace="name,icon,theme,allowBackup"
    >

    <activity
        android:name=".presentation.extra.ExtraMenuActivity"
        android:label="@string/extra_title"
        android:screenOrientation="portrait"
        />
</application>

I think androidX must declared here for launch test. I don't know how install his. Can you help me ?

Upvotes: 4

Views: 3601

Answers (2)

Q. Fan
Q. Fan

Reputation: 21

In my case, it is because I changed accidentally the Build Variant from debug to release.

The next day, all test references can not be resolved, and got INSTRUMENTATION_FAILED error when I tried to run the tests.

Just changed the Build Variant back to Debug. Then it worked again.

Upvotes: 0

rcarba
rcarba

Reputation: 683

This is a typical error when you change branches, some files that you compiled on the previous process stay at cache.

Just go to File/Invalidate Caches / Restart and it will be fixed.

Upvotes: 3

Related Questions