Java 运行浓缩咖啡测试时,在android studio中找不到属性android:forceQueryable
我已经使用android studio运行菜单中的录制浓缩咖啡测试选项录制了我的android应用程序浓缩咖啡测试。在记录的最后,我用自己的文件名保存了测试 单击“保存”按钮后,IDE会在应用程序模块的AndroidTest目录中自动创建文件。我在保存的文件上单击鼠标右键,然后单击“运行”。然后它提示我以下错误Java 运行浓缩咖啡测试时,在android studio中找不到属性android:forceQueryable,java,android,android-studio,android-espresso,android-espresso-recorder,Java,Android,Android Studio,Android Espresso,Android Espresso Recorder,我已经使用android studio运行菜单中的录制浓缩咖啡测试选项录制了我的android应用程序浓缩咖啡测试。在记录的最后,我用自己的文件名保存了测试 单击“保存”按钮后,IDE会在应用程序模块的AndroidTest目录中自动创建文件。我在保存的文件上单击鼠标右键,然后单击“运行”。然后它提示我以下错误 /Users/dehanwijesekara/Documents/ProjectName/app/build/intermediates/packated\u清单/debugAndroi
/Users/dehanwijesekara/Documents/ProjectName/app/build/intermediates/packated\u清单/debugAndroidTest/AndroidManifest.xml:24:AAPT:error:attribute-android:forceQueryable未找到。
下面是上面链接中的文件
<?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>
我正在使用Android Studio 4.1
请给出建议。以下是我所做的
在浓缩咖啡录制结束时,我注意到Android Studio自动将以下库添加到应用程序级别的Gradlebuild.xml
文件中
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0-alpha02'
以下是我根据手动添加的其他库
然后我将上述库更新为最新版本,如下所示(因为androidstudio建议使用最新版本,所以我进行了更新)
然后我将espresso contrib
的版本设置为espresso core
,如下所示
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.3.0'
注意,现在espresso contrib
和espresso core
都有3.3.0
我也从gradle构建文件中删除了以下库,但没有检查,如果它们持续存在会发生什么。因为我的目的不是测试,而是作为一种机器人程序持续地执行任务
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
最后,它成功了,我假设问题中出现上述错误的原因是版本不匹配。在我的情况下,此配置有效
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'
可能与……有关。你能试用AndroidX测试库的1.3.1-alpha02版本(或更高版本)吗?我不确定这是否有用。我最近也遇到了这个问题。当我在build.gradle(应用程序)中使用
androidTestImplementation'androidx时,我就可以工作了。测试:规则:1.3.0-alpha03'
而不是androidTestImplementation'androidx。测试:规则:1.3.1-alpha02'
ActivityTestRule
在较新版本中已被弃用。亲爱的@gosr,我尝试的结果无效。我找到了一个解决方案并进行了检查。亲爱的@hypergogeta,我也尝试了你的建议,但没有成功。我找到了一个解决方案并进行了检查。我必须保留Junit库,而这个解决方案不起作用。希望在下一个浓缩咖啡稳定版本中得到修复这对我来说很有效,我喝了浓缩咖啡3.4.0-alpha02,当我把它设置为3.3.0后,这个错误就消失了。@CodigoMorsa谢谢你让大家知道。
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
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'