[英]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-contrib
和espresso-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.