简体   繁体   English

运行 Espresso 测试时在 Android Studio 中找不到属性 android:forceQueryable

[英]attribute android:forceQueryable not found in Android studio when running Espresso test

I have recorded my android app Espresso test using android studio Record Espresso Test option in Run menu.我已经使用运行菜单中的 android studio Record Espresso Test选项记录了我的 android 应用程序 Espresso 测试。 In the end of the record I saved the test with a my own file name.在记录的最后,我用我自己的文件名保存了测试。

Once click the save button, IDE automatically created the file in AndroidTest directory of the app module.单击保存按钮后,IDE 会自动在应用模块的AndroidTest目录中创建文件。 I right click the saved file and clicked run.我右键单击保存的文件并单击运行。 Then it prompting me the following error.然后它提示我以下错误。

/Users/dehanwijesekara/Documents/ProjectName/app/build/intermediates/packaged_manifests/debugAndroidTest/AndroidManifest.xml:24: AAPT: error: attribute android:forceQueryable not found.

following is the file in the above link.以下是上述链接中的文件。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dehan.pizzago.test" >

<uses-sdk
    android:minSdkVersion="23"
    android:targetSdkVersion="29" />

<instrumentation
    android:name="androidx.test.runner.AndroidJUnitRunner"
    android:functionalTest="false"
    android:handleProfiling="false"
    android:label="Tests for com.dehan.pizzago"
    android:targetPackage="com.dehan.pizzago" />

<queries>
    <package android:name="androidx.test.orchestrator" />
    <package android:name="androidx.test.services" />
    <package android:name="com.google.android.apps.common.testing.services" />
</queries>

<uses-permission android:name="android.permission.REORDER_TASKS" />

<application
    android:debuggable="true"
    android:extractNativeLibs="false"
    android:forceQueryable="true" >
    <uses-library android:name="android.test.runner" />

    <activity
        android:name="androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity"
        android:theme="@android:style/Theme" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
        </intent-filter>
    </activity>
    <activity
        android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity"
        android:theme="@android:style/Theme" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
        </intent-filter>
    </activity>
    <activity
        android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity"
        android:theme="@android:style/Theme.Dialog" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
        </intent-filter>
    </activity>
</application>

I'm using Android Studio 4.1我正在使用 Android Studio 4.1

Please Advice.请指教。

Here is what I did.这是我所做的。

At the end of the espresso recording, I noticed Android Studio automatically adds the following library to the Gradle build.xml file of the app level.在 espresso 录制结束时,我注意到 Android Studio 自动将以下库添加到应用级别的 Gradle build.xml文件中。

androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0-alpha02'

The following are my other libraries I added manually by myself according to espresso setup guide in google android developers document .以下是我根据google android 开发人员文档中的 espresso 设置指南手动添加的其他库。

androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test:rules:1.1.0'

Then I updated the above libraries to the latest versions as below(Because android studio suggested the latest versions, so I updated).然后我将上述库更新到最新版本如下(因为android studio建议了最新版本,所以我更新了)。

androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test:rules:1.3.0'

Then I make the versions of espresso-contrib equal to espresso-core as below然后我使espresso-contrib的版本等于espresso-core如下

androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.3.0'

note, now both espresso-contrib and espresso-core having the version of 3.3.0注意,现在espresso-contribespresso-core的版本都是3.3.0

I removed the following libraries from my gradle build file also, haven't checked, what happened if they stay continuously.我也从我的 gradle 构建文件中删除了以下库,还没有检查,如果它们持续存在会发生什么。 because my purpose is not to test but do a task continuously as a kind of robot program.因为我的目的不是测试而是作为一种机器人程序连续执行任务。

testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'

Finally, it worked, I assume the reason for the above error in the question is because of the version mismatch.最后,它起作用了,我认为问题中出现上述错误的原因是版本不匹配。

In my case, this configuration is working.就我而言,此配置有效。

androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0-alpha03'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0-alpha03'
androidTestImplementation 'androidx.test:runner:1.3.1-alpha03'
androidTestImplementation 'androidx.test:rules:1.3.1-alpha03'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android:Espresso测试固件抛出“未找到测试..”异常 - Android : Espresso test FW throwing “No tests found..” exception 是否有一种简单的方法可以在 Espresso Android Studio 中为每个测试用例截屏 - Is there a Simple Way to Take Screenshot in Espresso Android Studio for Every Test Case 浓咖啡测试android中的多个匹配项 - multi matchs in espresso test android 为什么我在 Cloud Firestore (24.1.2) 中出现内部错误。 仅在运行浓缩咖啡测试时在我的 Android 应用中? - Why am I getting Internal error in Cloud Firestore (24.1.2). In my Android app only when running an espresso test? Android::android.support.test.espresso.NoMatchingViewException:在层次结构中没有找到匹配的视图 - Android::android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching Android Espresso UI测试-测试运行失败:由于“ java.lang.IllegalAccessError”,检测运行失败 - Android Espresso UI test - Test running failed: Instrumentation run failed due to 'java.lang.IllegalAccessError' Android espresso 在层次结构中没有找到匹配的视图 - Android espresso No views in hierarchy found matching android espresso 测试总是在文本匹配中失败 - android espresso test is fails always in text matching Android Espresso测试中的存根/模拟意图 - Stubbing/mocking intent in Android Espresso test 使用@Parameters的Android Espresso测试需要上下文 - Android Espresso test with @Parameters needs context
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM