android-cts-4.4-r3 gives NoClassDefFoundError while running cts-tradefed - android

I am trying to run Android CTS tests on Windows using Cygwin for android-cts-4.4_r3-linux_x86-arm.
When I run ./cts-tradefed I get following error:
java.lang.NoClassDefFoundError: com/android/cts/tradefed/command/CtsConsole
Caused by: java.lang.ClassNotFoundException: com.android.cts.tradefed.command.CtsConsole
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: com.android.cts.tradefed.command.CtsConsole. Program will exit.
Exception in thread "main"
Do I need to modify cts-tradefed?

The cts-tradefed file in only for linux I guess. For windows you have to create new batch file. e.g. cts_run.bat and put below code in file. Make sure you give path according to your system. Below code worked for Lollipop.
set SDK_ROOT=C:\Program Files\Java\jdk1.7.0_67
java -Xmx512M -cp C:\Users\Desktop\android-cts-5.0_r2-linux_x86-arm\android-cts\tools\cts-tradefed.jar;C:\Users\Desktop\android-cts-5.0_r2-linux_x86-arm\android-cts\tools\hosttestlib.jar;C:\Users\Desktop\android-cts-5.0_r2-linux_x86-arm\android-cts\tools\ddmlib-prebuilt.jar;C:\Users\Desktop\android-cts-5.0_r2-linux_x86-arm\android-cts\tools\tradefed-prebuilt.jar -DCTS_ROOT=C:\Users\Desktop\android-cts-5.0_r2-linux_x86-arm com.android.cts.tradefed.command.CtsConsole

Related

(Internal Error) Opening Android Studio in School Computer

I have declared both system and user environment variables and setup everything I thought was needed. Getting this screen when attempting to open:
I have reinstalled Android Studio with admin privileges. Still nothing.
Does anyone know what the problem is? Let me know if information is insufficient.
edit 1: copyable error message
Internal Error. Please report to https://code.google.com/p/android/issues
com.intellij.ide.plugins.PluginManager$StartupAbortedException: Fatal error initializing 'com.intellij.debugger.DebuggerManager'
at com.intellij.ide.plugins.PluginManager.handleComponentError(PluginManager.java:256)
at com.intellij.openapi.components.impl.PlatformComponentManagerImpl.handleInitComponentError(PlatformComponentManagerImpl.java:43)
at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter.getComponentInstance(ComponentManagerImpl.java:540)
at com.intellij.openapi.components.impl.ComponentManagerImpl.createComponents(ComponentManagerImpl.java:123)
at com.intellij.openapi.components.impl.ComponentManagerImpl.init(ComponentManagerImpl.java:107)
at com.intellij.openapi.components.impl.ComponentManagerImpl.init(ComponentManagerImpl.java:90)
at com.intellij.openapi.project.impl.ProjectImpl.init(ProjectImpl.java:282)
at com.intellij.openapi.project.impl.ProjectManagerImpl.initProject(ProjectManagerImpl.java:231)
at com.intellij.openapi.project.impl.ProjectManagerImpl.access$300(ProjectManagerImpl.java:68)
at com.intellij.openapi.project.impl.ProjectManagerImpl$3.run(ProjectManagerImpl.java:311)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:446)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:392)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeNonCancelableSection(CoreProgressManager.java:170)
at com.intellij.openapi.project.impl.ProjectManagerImpl.getDefaultProject(ProjectManagerImpl.java:306)
at com.android.tools.idea.sdk.IdeSdks.getAndroidSdkPath(IdeSdks.java:90)
at com.android.tools.idea.startup.GradleSpecificInitializer.setupSdks(GradleSpecificInitializer.java:282)
at com.android.tools.idea.startup.GradleSpecificInitializer.run(GradleSpecificInitializer.java:114)
at com.android.tools.idea.AndroidInitialConfigurator.activateAndroidStudioInitializerExtensions(AndroidInitialConfigurator.java:198)
at com.android.tools.idea.AndroidInitialConfigurator.<init>(AndroidInitialConfigurator.java:65)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.picocontainer.defaults.InstantiatingComponentAdapter.newInstance(InstantiatingComponentAdapter.java:193)
at org.picocontainer.defaults.ConstructorInjectionComponentAdapter$1.run(ConstructorInjectionComponentAdapter.java:220)
at org.picocontainer.defaults.ThreadLocalCyclicDependencyGuard.observe(ThreadLocalCyclicDependencyGuard.java:53)
at org.picocontainer.defaults.ConstructorInjectionComponentAdapter.getComponentInstance(ConstructorInjectionComponentAdapter.java:248)
at com.intellij.util.pico.ConstructorInjectionComponentAdapter.getComponentInstance(ConstructorInjectionComponentAdapter.java:59)
at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter.getComponentInstance(ComponentManagerImpl.java:499)
at com.intellij.openapi.components.impl.ComponentManagerImpl.createComponents(ComponentManagerImpl.java:123)
at com.intellij.openapi.application.impl.ApplicationImpl.access$801(ApplicationImpl.java:92)
at com.intellij.openapi.application.impl.ApplicationImpl$12.run(ApplicationImpl.java:500)
at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:142)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:446)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:392)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:127)
at com.intellij.openapi.application.impl.ApplicationImpl.createComponents(ApplicationImpl.java:516)
at com.intellij.openapi.components.impl.ComponentManagerImpl.init(ComponentManagerImpl.java:107)
at com.intellij.openapi.application.impl.ApplicationImpl.load(ApplicationImpl.java:458)
at com.intellij.openapi.application.impl.ApplicationImpl.load(ApplicationImpl.java:450)
at com.intellij.idea.IdeaApplication.run(IdeaApplication.java:197)
at com.intellij.idea.MainImpl$1$1$1.run(MainImpl.java:52)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:366)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: com/sun/jdi/Value
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.proxy.$Proxy47.<clinit>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.reflect.Proxy.newProxyInstance(Unknown Source)
at com.intellij.util.EventDispatcher.<init>(EventDispatcher.java:75)
at com.intellij.util.EventDispatcher.create(EventDispatcher.java:42)
at com.intellij.debugger.impl.DebuggerStateManager.<init>(DebuggerStateManager.java:29)
at com.intellij.debugger.impl.DebuggerManagerImpl$MyDebuggerStateManager.<init>(DebuggerManagerImpl.java:606)
at com.intellij.debugger.impl.DebuggerManagerImpl$MyDebuggerStateManager.<init>(DebuggerManagerImpl.java:606)
at com.intellij.debugger.impl.DebuggerManagerImpl.<init>(DebuggerManagerImpl.java:81)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.picocontainer.defaults.InstantiatingComponentAdapter.newInstance(InstantiatingComponentAdapter.java:193)
at org.picocontainer.defaults.ConstructorInjectionComponentAdapter$1.run(ConstructorInjectionComponentAdapter.java:220)
at org.picocontainer.defaults.ThreadLocalCyclicDependencyGuard.observe(ThreadLocalCyclicDependencyGuard.java:53)
at org.picocontainer.defaults.ConstructorInjectionComponentAdapter.getComponentInstance(ConstructorInjectionComponentAdapter.java:248)
at com.intellij.util.pico.ConstructorInjectionComponentAdapter.getComponentInstance(ConstructorInjectionComponentAdapter.java:59)
at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter.getComponentInstance(ComponentManagerImpl.java:499)
... 56 more
Caused by: java.lang.ClassNotFoundException: com.sun.jdi.Value
at com.intellij.util.lang.UrlClassLoader.findClass(UrlClassLoader.java:207)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 80 more
edit 2: my JAVA_HOME user variable
Does it have to be like this in system variables as well?
In order to fix this issue, please ensure your JAVA_HOME is pointing to C:\Program Files\Java\jdk1.8.0_102 (Java SE Development Kit) instead of C:\Program Files\Java\jre1.8.0_102 (Java SE Runtime Environment).
In fact, JRE is located inside JDK folder.
If you haven't installed JDK yet, please do it following next link: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html?ssSourceSiteId=otnes
Got from:
https://code.google.com/p/android/issues/detail?id=211766
It's a JDK issue with Android Studio.
Try to set JAVA_HOME to JDK folder
And to set %JAVA_HOME%\bin to the Path environment variable with the JAVA_HOME environment variable pointing to the jdk folder.
Remember note: You might need to restart Windows after changing the environment variable
Sources :
code.google.com/p/android/issues/detail?id=211766
Android Studio Won't Start (com.sun.jdi.Value Not Found)
How to set java_home on Windows 7?
Try turning on HAXM at the boot time of your pc and checking all the required plugins of Android studio.
Thanks..

Netty ObjectEncoders/ObjectDecoders on android causing StreamCorruptedException

I want to write a Client on android phone and send an Object to a Server running on my windows PC (using ObjectDecoderInputStream ), but had these Exception
Exception
java.io.StreamCorruptedException: unexpected end of block data
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.access$300(Unknown Source)
at java.io.ObjectInputStream$GetFieldImpl.readFields(Unknown Source)
at java.io.ObjectInputStream.readFields(Unknown Source)
at java.net.InetSocketAddress.readObject(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at org.jboss.netty.handler.codec.serialization.ObjectDecoderInputStream.readObject(ObjectDecoderInputStream.java:115)
at MainActivity.main(MainActivity.java:30)
But when I use CompatibleObjectEncoder/Decoder on my phone and ObjectInputStream on my PC, it works fine. And if I change the android code to Java code, and run the client on my PC to send my self the Object using ObjectEncoder and its correlated InputStream, it works fine.
By the way, I use netty 3.6.3 final and my android device is 2.3.7 gingerbread (which uses jre 1.5 or 1.6), my PC is jre 1.7, could that be a problem?
Sounds similair to my problem here - I never got to the bottom of it, but changing the JVM so both ends run the same version stopped the error

How to use Android-Libs in JUnit-Test Cases?

I want to use JUNIT for some network classes in my Android-Project. I am using Apache HttpClient which is already included in android. But when I run my junit test it comes to an exception. I included all my lib files in the Junit-Testrunner. But obviously it is not enough because the HttpClient is not found. Does some know what I am doing wrong?
Here is the exception
java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient
at de.srs.android.pdixuploader.network.test.ClientAppTest.testCheckLogin(ClientAppTest.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: org.apache.http.client.HttpClient
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 19 more
I resolved this by adding the JUnit library to my project:
Open project's Properties > Java Build Path
Open the Libraries tab
Click Add Library
Select JUnit
Click Next
Make sure that the correct version of JUnit is selected in the dropdown
Click Finish

java.lang.NoClassDefFoundError: android/test/ActivityInstrumentationTestCase2

I have created test project...I have updloaded junit.jar in the (Run time configuration class path --> user entries --> junit.jar
I am getting below errror when i run the code...
java.lang.NoClassDefFoundError: android/test/ActivityInstrumentationTestCase2
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: android.test.ActivityInstrumentationTestCase2
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 17 more
You need to run it as Android JUnit test, instead of JUnit test.
Go to the project in the project explorer->right click->Android JUnit test
android.test.ActivityInstrumentationTestCase2 is not in the JUnit JAR that you claim to have added to classpath.
That looks like one of yours.
Did you compile the code? If not, please do so.
Did you add the path to the location where your .class files are written? If not, please do so.
Follow these instructions: http://developer.android.com/guide/developing/testing/testing_eclipse.html
Basically, you don't have to add junit.jar to your classpath.
I had the similar problem. For me Changing the "Order and Export" (properties->build Path->Order and Export) of robotium-solo.jar i.e moving it to the top and explicitly selecting run as 'android JUnit test' by right clicking the project solved the problem. Also try running the sample project provided.
It might sound strange. but all you need to do is import solo before you import the class and it works. At least it did for me. i dont know why i tried that but all it needed was to cut the import com.jayway.android.robotium.solo.Solo; and paste it just after the package.

NoClassDefFoundError: com/google/common/base/Predicate when importing MonkeyRunner in Jython

I want to use MonkeyRunner to generate MotionEvent (from screen touch). I have read the info on
http://developer.android.com/guide/developing/tools/monkeyrunner_concepts.html.
The problem is that for this jython program:
from com.android.monkeyrunner import MonkeyRunner
if __name__ == '__main__':
# Connects to the current device, returning a MonkeyDevice object
device = MonkeyRunner.waitForConnection()
I get the following error when executed:
Traceback (most recent call last):
File "C:\Documents and Settings\jjungb00\python\workspace\monkey\src\runner.py", line 6, in <module>
from com.android.monkeyrunner import MonkeyRunner
java.lang.NoClassDefFoundError: com/google/common/base/Predicate
at com.android.monkeyrunner.MonkeyRunner.classDictInit(MonkeyRunner.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyJavaType.init(PyJavaType.java:534)
at org.python.core.PyType.createType(PyType.java:1264)
at org.python.core.PyType.addFromClass(PyType.java:1201)
at org.python.core.PyType.fromClass(PyType.java:1291)
...
skipping some stack trace
...
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Predicate
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
...
I have added monkeyrunner.jar from the android sdk tool/lib as an external library.
I'm running on XP, with jython 2.5.2.
Any idea what to do? I guess I must add another library, but I do not know where or which.
You need to add the Google Collections library - currently renamed to Guava. Look for guavalib.jar in the android SDK directory.

Categories

Resources