FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugAndroidTestJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
解决了,原因是创建项目语言选择错误,选了 kotlin,后来重新创建一个java的就成功了。另外还有adb.exe打开失败问题,下载了adb的最新安装包把文件替换了就解决了
01/30 18:29:55: Launching 'DemoTest()' on Android711.
Running tests
Starting Gradle Daemon...
Gradle Daemon started in 2 s 897 ms
> Configure project :app
WARNING:The option setting 'android.experimental.testOptions.emulatorSnapshots.maxSnapshotsForTestFailures=0' is experimental.
> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :app:checkDebugAarMetadata UP-TO-DATE
> Task :app:generateDebugResValues UP-TO-DATE
> Task :app:generateDebugResources UP-TO-DATE
> Task :app:mergeDebugResources UP-TO-DATE
> Task :app:packageDebugResources UP-TO-DATE
> Task :app:parseDebugLocalResources UP-TO-DATE
> Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
> Task :app:extractDeepLinksDebug UP-TO-DATE
> Task :app:processDebugMainManifest UP-TO-DATE
> Task :app:processDebugManifest UP-TO-DATE
> Task :app:processDebugManifestForPackage UP-TO-DATE
> Task :app:processDebugResources UP-TO-DATE
> Task :app:compileDebugKotlin UP-TO-DATE
> Task :app:javaPreCompileDebug UP-TO-DATE
> Task :app:compileDebugJavaWithJavac UP-TO-DATE
> Task :app:bundleDebugClasses UP-TO-DATE
> Task :app:preDebugAndroidTestBuild SKIPPED
> Task :app:compileDebugAndroidTestAidl NO-SOURCE
> Task :app:processDebugAndroidTestManifest UP-TO-DATE
> Task :app:generateDebugAndroidTestBuildConfig UP-TO-DATE
> Task :app:checkDebugAndroidTestAarMetadata UP-TO-DATE
> Task :app:compileDebugAndroidTestRenderscript NO-SOURCE
> Task :app:generateDebugAndroidTestResValues UP-TO-DATE
> Task :app:generateDebugAndroidTestResources UP-TO-DATE
> Task :app:mergeDebugAndroidTestResources UP-TO-DATE
> Task :app:processDebugAndroidTestResources UP-TO-DATE
> Task :app:compileDebugAndroidTestKotlin UP-TO-DATE
> Task :app:javaPreCompileDebugAndroidTest UP-TO-DATE
> Task :app:compileDebugAndroidTestJavaWithJavac
D:\Android\ASWorkspace\MKApplication\app\src\androidTest\java\com\mk\MKTest.java:5: 错误: 程序包android.support.test.uiautomator不存在
import android.support.test.uiautomator.UiDevice;
^
D:\Android\ASWorkspace\MKApplication\app\src\androidTest\java\com\mk\MKTest.java:16: 错误: 找不到符号
public UiDevice mUidevice;
^
符号: 类 UiDevice
位置: 类 MKTest
D:\Android\ASWorkspace\MKApplication\app\src\androidTest\java\com\mk\MKTest.java:13: 错误: 找不到符号
@RunWith(AndriodJUnit4.class)
^
符号: 类 AndriodJUnit4
D:\Android\ASWorkspace\MKApplication\app\src\androidTest\java\com\mk\MKTest.java:21: 错误: 找不到符号
mUidevice= UiDevice.getInstance(mInstrumentation);
^
符号: 变量 UiDevice
位置: 类 MKTest
4 个错误
> Task :app:compileDebugAndroidTestJavaWithJavac FAILED
25 actionable tasks: 1 executed, 24 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugAndroidTestJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 16s