How can I fix: Execution failed for task ':app:connectedDebugAndroidTest'? - android

I have been running tests on an emulator for a while successfully for the App I am currently working and all of a sudden they are not running anymore. I have tried with 2 different emulators, I have not tried on a real device. I have also tried to uninstall the app from the emulator.
This happens for all instrument tests on the current app.
Here is the stacktrace from when trying to run the the test:
> Task :app:connectedDebugAndroidTest
Device provider <com.android.tools.utp.plugins.deviceprovider.ddmlib.DdmlibAndroidDeviceProvider> failed trying to provide device controller.
Android device (emulator-5554) is not found.
com.google.testing.platform.core.device.DeviceProviderException: ErrorName: UNDETERMINED
NameSpace: com.google.testing.platform
ErrorCode: 3999
Message: Android device (emulator-5554) is not found.
at com.android.tools.utp.plugins.deviceprovider.ddmlib.DdmlibAndroidDeviceProvider.provideDevice(DdmlibAndroidDeviceProvider.kt:116)
at com.google.testing.platform.executor.DeviceProviderProxy$provideDevice$2.invoke(DeviceProviderProxy.kt:118)
at com.google.testing.platform.executor.DeviceProviderProxy$provideDevice$2.invoke(DeviceProviderProxy.kt:117)
at com.google.testing.platform.core.telemetry.common.noop.NoopDiagnosticsScope.recordEvent(NoopDiagnosticsScope.kt:35)
at com.google.testing.platform.core.telemetry.TelemetryKt.recordEvent(Telemetry.kt:66)
at com.google.testing.platform.executor.DeviceProviderProxy.provideDevice(DeviceProviderProxy.kt:114)
at com.google.testing.platform.executor.SingleDeviceExecutor$execute$deviceController$1.invoke(SingleDeviceExecutor.kt:68)
at com.google.testing.platform.executor.SingleDeviceExecutor$execute$deviceController$1.invoke(SingleDeviceExecutor.kt:68)
at com.google.testing.platform.executor.SingleDeviceExecutor.runUnlessCancelled(SingleDeviceExecutor.kt:105)
at com.google.testing.platform.executor.SingleDeviceExecutor.execute(SingleDeviceExecutor.kt:68)
at com.google.testing.platform.RunnerImpl.run(RunnerImpl.kt:108)
at com.google.testing.platform.server.strategy.NonInteractiveServerStrategy$run$4.invoke(NonInteractiveServerStrategy.kt:80)
at com.google.testing.platform.server.strategy.NonInteractiveServerStrategy$run$4.invoke(NonInteractiveServerStrategy.kt:79)
at com.google.testing.platform.core.telemetry.common.noop.NoopDiagnosticsScope.recordEvent(NoopDiagnosticsScope.kt:35)
at com.google.testing.platform.core.telemetry.TelemetryKt.recordEvent(Telemetry.kt:66)
at com.google.testing.platform.server.strategy.NonInteractiveServerStrategy.run(NonInteractiveServerStrategy.kt:79)
at com.google.testing.platform.main.MainKt$main$4.invokeSuspend(Main.kt:67)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274)
at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
at com.google.testing.platform.main.MainKt.main(Main.kt:66)
at com.google.testing.platform.main.MainKt.main$default(Main.kt:34)
at com.google.testing.platform.main.MainKt.main(Main.kt)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.google.testing.platform.launcher.Launcher.main(Launcher.java:149)

I've had the same issue using platform-tools 33.0.3 for Linux x86-64, same version on a macOS M1 worked fine. After I tried with version 32.0.0 it worked. You can download it here.

I upgraded AS to Electric Eel | 2022.1.1 (it did not work at the time). When I tried to run the test after a few days and after switching my computer off, it works fine.
I thinking all I had to do is restart the computer.

Related

Option configuration-cache doesn't accept value 'true'. Possible values are [OFF, ON, WARN]

I'm trying to build an Android application in Android studio. However, getting the error as Option configuration-cache doesn't accept value 'true'. Possible values are [OFF, ON, WARN]. Checked all the gradle files on where I can update this configuration-cache option. But no luck. I tried to run the gradle task with --stacktrace. and below is the output. Where Can I update this option? Kindly help. Thanks!
Android Gradle plugin version : 4.1.2
Gradle version : 6.5
Stack trace :
* Exception is:
java.lang.RuntimeException: Option configuration-cache doesn't accept value 'true'. Possible values are [OFF, ON, WARN]
at org.gradle.internal.buildoption.EnumBuildOption.getValue(EnumBuildOption.java:87)
at org.gradle.internal.buildoption.EnumBuildOption.applyTo(EnumBuildOption.java:72)
at org.gradle.internal.buildoption.EnumBuildOption.applyFromProperty(EnumBuildOption.java:50)
at org.gradle.launcher.cli.converter.PropertiesToStartParameterConverter.convert(PropertiesToStartParameterConverter.java:34)
at org.gradle.launcher.cli.ParametersConverter.convert(ParametersConverter.java:88)
at org.gradle.launcher.cli.ParametersConverter.convert(ParametersConverter.java:37)
at org.gradle.launcher.cli.BuildActionsFactory.createAction(BuildActionsFactory.java:82)
at org.gradle.launcher.cli.DefaultCommandLineActionFactory$ParseAndBuildAction.createAction(DefaultCommandLineActionFactory.java:299)
at org.gradle.launcher.cli.DefaultCommandLineActionFactory$ParseAndBuildAction.execute(DefaultCommandLineActionFactory.java:289)
at org.gradle.launcher.cli.DefaultCommandLineActionFactory$ParseAndBuildAction.execute(DefaultCommandLineActionFactory.java:266)
at org.gradle.launcher.cli.DebugLoggerWarningAction.execute(DebugLoggerWarningAction.java:82)
at org.gradle.launcher.cli.DebugLoggerWarningAction.execute(DebugLoggerWarningAction.java:30)
at org.gradle.launcher.cli.WelcomeMessageAction.execute(WelcomeMessageAction.java:92)
at org.gradle.launcher.cli.WelcomeMessageAction.execute(WelcomeMessageAction.java:38)
at org.gradle.launcher.cli.NativeServicesInitializingAction.execute(NativeServicesInitializingAction.java:44)
at org.gradle.launcher.cli.NativeServicesInitializingAction.execute(NativeServicesInitializingAction.java:26)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:41)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:26)
at org.gradle.launcher.cli.DefaultCommandLineActionFactory$WithLogging.execute(DefaultCommandLineActionFactory.java:259)
at org.gradle.launcher.Main.doAction(Main.java:35)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:50)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
at org.gradle.launcher.GradleMain.main(GradleMain.java:31)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:31)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:108)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Sounds silly, but just changed the configuration-config option as suggested by the error in user/.gradle/gradle.properties, and project compiled succcessfully. But other android studio projects compile successfully with value true. Maybe this has to do something with the gradle version.

Unit Tests work correctly when running but not when debugging in Android Studio 4.1

I upgraded android studio and I get this weird behaviour
when I run my unit tests they run and complete correctly (I introduced some errors to make sure it was so)
but when I put a breakpoint and use debug tests in java the jvm crashes with this error:
"C:\Program Files\Android\Android Studio4\jre\bin\java.exe" - agentlib:jdwp=transport=dt_socket,address=127.0.0.1:64493,suspend=y,server=n -ea -javaagent:C:\Users\imavrelos\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlinx\kotlinx-coroutines-core-jvm\1.3.9\4be434f5e86c1998a273e7f19a7286440894f0b0\kotlinx-coroutines-core-jvm-1.3.9.jar -Didea.test.cyclic.buffer.size=1048576 -javaagent:C:\Users\imavrelos\AppData\Local\Google\AndroidStudio4.1\groovyHotSwap\gragent.jar -javaagent:C:\Users\imavrelos\AppData\Local\Google\AndroidStudio4.1\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Android\Android Studio4\lib\idea_rt.jar" com.intellij.rt.execution.CommandLineWrapper C:\Users\imavrelos\AppData\Local\Temp\idea_classpath1657759720 com.intellij.rt.junit.JUnitStarter -ideVersion5 #w#C:\Users\imavrelos\AppData\Local\Temp\idea_working_dirs_junit.tmp #C:\Users\imavrelos\AppData\Local\Temp\idea_junit.tmp -socket64492
Connected to the target VM, address: '127.0.0.1:64493', transport: 'socket'
java.lang.NoClassDefFoundError: kotlin/collections/AbstractMutableMap
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:757)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
at kotlinx.coroutines.debug.internal.DebugProbesImpl.<clinit>(DebugProbesImpl.kt:30)
at kotlinx.coroutines.debug.AgentPremain.<clinit>(AgentPremain.kt:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.lang.ClassNotFoundException: kotlin.collections.AbstractMutableMap
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
... 20 more
FATAL ERROR in native method: processing of -javaagent failed
Disconnected from the target VM, address: '127.0.0.1:64493', transport: 'socket'
Process finished with exit code 1
Exception in thread "main"
has anyone got this error? any suggestions on how to fix it?
I fixed it by editing the current Run/Debug Configuration and choosing JAR Manifest in the Shorten command line option.
A similar error can also be caused by using kotlinx-coroutines-core, but it seems to depend on the IDEA version or library.
In my case, debug stopped working after updating IDEA Ultimate to version 2021.2
I fixed this error by editing the current Run/Debug Configuration and disabling the "Shorten command line" option. Before it was set to "classpath file" which seems to bring up the above error in some cases.
I wrote a unit test for a library. When running with usual Ctrl + Shift + F10 it executed, but when tried to debug the test, it didn't run with the error: 'Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/collections/AbstractMutableMap'.
Then I moved the unit test to instrumentation test.
If you are facing this issue in a web-based Gradle project and you are not utilizing kotlin in your project, In that case following steps could help you out:
Check checkbox for 'disable coroutine agent'
File > Settings > Build, Execution, Deployment > Debugger > Data Views
Kotlin > Disable coroutine agent

Fedora - android studio is not running

I want to run android studio in fedora 25.
I run ./studio.sh
and I get this error:
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=350m;support was removed in 8.0
No protocol specified
Start Failed: Internal Error. Failed to initialize graphics environment
java.awt.AWTError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:65)
at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:115)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:74)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:103)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:82)
at sun.awt.X11.XToolkit.<clinit>(XToolkit.java:126)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at java.awt.Toolkit$2.run(Toolkit.java:860)
at java.awt.Toolkit$2.run(Toolkit.java:855)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:854)
at java.awt.Toolkit.getEventQueue(Toolkit.java:1734)
at java.awt.EventQueue.isDispatchThread(EventQueue.java:1043)
at javax.swing.SwingUtilities.isEventDispatchThread(SwingUtilities.java:1361)
at javax.swing.text.StyleContext.reclaim(StyleContext.java:454)
at javax.swing.text.StyleContext.addAttribute(StyleContext.java:311)
at javax.swing.text.html.StyleSheet.addAttribute(StyleSheet.java:578)
at javax.swing.text.StyleContext$NamedStyle.addAttribute(StyleContext.java:1501)
at javax.swing.text.StyleContext$NamedStyle.setName(StyleContext.java:1312)
at javax.swing.text.StyleContext$NamedStyle.<init>(StyleContext.java:1259)
at javax.swing.text.StyleContext.addStyle(StyleContext.java:107)
at javax.swing.text.StyleContext.<init>(StyleContext.java:87)
at javax.swing.text.html.StyleSheet.<init>(StyleSheet.java:166)
at javax.swing.text.html.HTMLEditorKit.getStyleSheet(HTMLEditorKit.java:391)
at com.intellij.util.ui.UIUtil.<clinit>(UIUtil.java:98)
at com.intellij.ide.plugins.PluginManager.start(PluginManager.java:73)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.ide.Bootstrap.main(Bootstrap.java:39)
at com.intellij.idea.Main.main(Main.java:113)
any idea how to fix this problem? I tried to unset Display or export Display:=0 and I did not get any solution
Fedora 25 is not using XOrg anymore by default. We moved to Wayland and Java probably does not handle that. It would be nice to report the problem to Android Studio developers (not here).
Anyway, you can workaround it by running Fedora using old X. Select the "GNOME on XOrg when logging into your account:
I got the below issue because of running as a root user. Once I exit from the root user and tried ./studio.sh it worked perfectly :)
Start Failed: Internal Error. Failed to initialize graphics environment
I got this issue because I was running as root user. This will work fine if you don't change your privilege to the super user

How want to Create in Eclipse and run Appium test on Android device?

How to create in Eclipse and run your Appium test on the iOS device (not emulator) where app is installed prior to the execution of the test script?
from the link above as I am trying to follow the steps. I am stuck at step 11 as I am trying to get my android device to set up with Eclipse and run Appium. I am having problem with following codes as folows
capabilities.setCapability("platformName", "ios"); (changed "IOS" to "Android")
capabilities.setCapability("deviceName","iOS"); (changed "IOS" to "Android")
capabilities.setCapability("udid", “<<<your iOS device UDID>>>”); ( I know my IMEI number for the device)
capabilities.setCapability("app", “<<<your app’s bundle id>>>”); (?????)
And then when I continue with the steps seems like it's not working as it should especially with step 15 & 16. When I copy and paste command in step 16 I get the follow messages as follows:
mvn -Dtest=test.java.com.saucelabs.appium.AppiumIOSTest test
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/maven/cli/MavenCli : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:401)
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:254)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
at org.codehaus.plexus.classworlds.launcher.Launcher.getMainClass(Launcher.java:144)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:266)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
what I am doing wrong?

Android Studio Doesn't Start on Ubuntu

I started using Android Studio after a couple of days, Suddenly Android Studio didn't start . When I started it through terminal i.e "Studio" Command. Got the Following Error.
Java HotSpot(TM) Server VM warning: ignoring option MaxPermSize=350m; support was removed in 8.0
Start Failed: Internal Error. Please report to https://https://code.google.com/p/android/issues
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.ide.Bootstrap.main(Bootstrap.java:39)
at com.intellij.idea.Main.main(Main.java:103)
Caused by: java.lang.UnsatisfiedLinkError: /usr/lib/jvm/jdk1.8.0_91/jre/lib/i386/libawt_xawt.so: libXrender.so.1: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1845)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at java.awt.Toolkit$3.run(Toolkit.java:1636)
at java.awt.Toolkit$3.run(Toolkit.java:1634)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.loadLibraries(Toolkit.java:1633)
at java.awt.Toolkit.<clinit>(Toolkit.java:1668)
at java.awt.Cursor.<clinit>(Cursor.java:195)
at javax.swing.text.html.HTMLEditorKit.<clinit>(HTMLEditorKit.java:623)
at com.intellij.util.ui.UIUtil.<clinit>(UIUtil.java:97)
at com.intellij.ide.plugins.PluginManager.start(PluginManager.java:71)
... 6 more
Also, an UI exception occurred on attempt to show above message:
java.lang.NoClassDefFoundError: Could not initialize class java.awt.Toolkit
at java.awt.Component.<clinit>(Component.java:593)
at com.intellij.idea.Main.showMessage(Main.java:336)
at com.intellij.idea.Main.showMessage(Main.java:312)
at com.intellij.idea.Main.showMessage(Main.java:291)
at com.intellij.idea.Main.main(Main.java:106)
I have re-installed java 7 and java 8 both . Also Reinstalled Android Studio. But still there was no help.
I had installed octave before, was that a problem?
To resolve the problem you should install JDK 64bit. From the comments, you have installed 32-bit JDK
I was having the same issue. I killed the app and reopened. It fixed the issue for me.

Categories

Resources