I'm running JUnit tests with Android studio, it's great.
In order to do so, I had to fight a bit and add the following to the VM options, because adding junit 4.12 to the Dependencies of the Application in the Project Structure did not work.
My question is : why, and am I doing something wrong ?
-ea -classpath "C:\Users\obfuscated\.gradle\caches\modules-2\files-2.1\junit\junit\4.12\2973d150c0dc1fefe998f834810d68f278ea58ec\junit-4.12.jar;D:\Program Files\Android\Android Studio\lib\idea_rt.jar;D:\Program Files\Android\Android Studio\plugins\junit\lib\junit-rt.jar;D:\Android\sdk\platforms\android-21\android.jar;D:\Android\sdk\platforms\android-21\data\res;D:\Android\projets\AndroidStudioProjects\ElevationDrag\Application\build\intermediates\classes\test\debug;D:\Android\projets\AndroidStudioProjects\ElevationDrag\Application\build\intermediates\classes\debug;C:\Users\obfuscated\.gradle\caches\modules-2\files-2.1\org.objenesis\objenesis\1.0\9b473564e792c2bdf1449da1f0b1b5bff9805704\objenesis-1.0.jar;C:\Users\obfuscated\.gradle\caches\modules-2\files-2.1\org.hamcrest\hamcrest-core\1.3\42a25dc3219429f0e5d060061f71acb49bf010a0\hamcrest-core-1.3.jar;D:\Android\projets\AndroidStudioProjects\ElevationDrag\Application\build\intermediates\exploded-aar\com.android.support\support-v4\21.0.3\libs\internal_impl-21.0.3.jar;D:\Android\projets\AndroidStudioProjects\ElevationDrag\Application\build\intermediates\exploded-aar\com.android.support\support-v4\21.0.3\classes.jar;D:\Android\projets\AndroidStudioProjects\ElevationDrag\Application\build\intermediates\exploded-aar\com.android.support\support-v4\21.0.3\res;D:\Android\sdk\extras\android\m2repository\com\android\support\support-annotations\21.0.3\support-annotations-21.0.3.jar;D:\Android\projets\AndroidStudioProjects\ElevationDrag\Application\build\intermediates\exploded-aar\com.android.support\support-v13\21.0.2\libs\internal_impl-21.0.2.jar;D:\Android\projets\AndroidStudioProjects\ElevationDrag\Application\build\intermediates\exploded-aar\com.android.support\support-v13\21.0.2\classes.jar;D:\Android\projets\AndroidStudioProjects\ElevationDrag\Application\build\intermediates\exploded-aar\com.android.support\support-v13\21.0.2\res;C:\Users\obfuscated\.gradle\caches\modules-2\files-2.1\org.mockito\mockito-core\1.9.5\c3264abeea62c4d2f367e21484fbb40c7e256393\mockito-core-1.9.5.jar;D:\Android\projets\AndroidStudioProjects\ElevationDrag\Application\build\intermediates\exploded-aar\com.android.support\cardview-v7\21.0.2\res;D:\Android\projets\AndroidStudioProjects\ElevationDrag\Application\build\intermediates\exploded-aar\com.android.support\cardview-v7\21.0.2\classes.jar;D:\Android\projets\AndroidStudioProjects\ElevationDrag\Application\build\intermediates\mockable-android-21.jar"
If I follow instructions given here I find myself with the following error :
!!! JUnit version 3.8 or later expected:
java.lang.RuntimeException: Stub!
at junit.runner.BaseTestRunner.<init>(BaseTestRunner.java:5)
at junit.textui.TestRunner.<init>(TestRunner.java:54)
at junit.textui.TestRunner.<init>(TestRunner.java:48)
at junit.textui.TestRunner.<init>(TestRunner.java:41)
at com.intellij.rt.execution.junit.JUnitStarter.junitVersionChecks(JUnitStarter.java:190)
at com.intellij.rt.execution.junit.JUnitStarter.canWorkWithJUnitVersion(JUnitStarter.java:173)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:56)
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:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Process finished with exit code -3
Android class has to be run in a device or emulator. If not you need some means to mock the android.jar
Please take a look at:
http://tools.android.com/tech-docs/unit-testing-support
or
http://robolectric.org/
Related
I want to use sonarQube to analyze an android project.
While I am trying to install SonarQube Scanner, I have faced some problem.
I received the following error when running sonar-scanner command from the project directory.
*I have followed the Installation steps from this link https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner
*I am using SonarQube 6.5 and SonarScanner 3.0.3
ERROR: Error during SonarQube Scanner execution
org.sonar.squidbridge.api.AnalysisException: Please provide compiled
classes of
your project with sonar.java.binaries property
at org.sonar.java.JavaClasspath.init(JavaClasspath.java:59)
at org.sonar.java.AbstractJavaClasspath.getElements (AbstractJavaClasspath.java:281)
at org.sonar.java.SonarComponents.getJavaClasspath(SonarComponents.java:
141)
at org.sonar.java.JavaSquid.<init>(JavaSquid.java:83)
at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:8
3)
at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)
at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:88)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java
:82)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java
:68)
at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseE
xecutor.java:78)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanCon
tainer.java:179)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentC
ontainer.java:144)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer
.java:129)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer
.java:261)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectSc
anContainer.java:256)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanC
ontainer.java:245)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentC
ontainer.java:144)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer
.java:129)
at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47)
at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:
84)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentC
ontainer.java:144)
at
org.sonar.core.platform.ComponentContainer.execute (ComponentContainerjava:129)
at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContain
er.java:119)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:116)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.exec
ute(BatchIsolatedLauncher.java:63)
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 org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(Iso
latedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner
.java:233)
at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScann
er.java:151)
at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:123)
at org.sonarsource.scanner.cli.Main.execute(Main.java:77)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug
logging
.
If you have any solution for this problem, please help me.
You need to build your project before the analysis. Let's say that your project structure is equal to:
project
|- src
|- dependencies
|- classes
then you should configure:
sonar.sources = src
sonar.java.libraries = dependencies/**/*.jar
sonar.java.binaries = classes
Read more at: Java Plugin and Bytecode
After OS update from Windows 7 to Windows 10, I'm facing following error:
Apache Maven
intelligent projects ~
v. 1.0.2
javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not
at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:93)
at org.apache.maven.jelly.JellyUtils.compileScript(JellyUtils.java:202)
at org.apache.maven.jelly.JellyUtils.compileScript(JellyUtils.java:180)
at org.apache.maven.jelly.JellyUtils.compileScript(JellyUtils.java:146)
at org.apache.maven.plugin.PluginManager.loadScript(PluginManager.java:1109)
at org.apache.maven.plugin.PluginManager.runScript(PluginManager.java:1135)
at org.apache.maven.plugin.PluginManager.initialiseHousingPluginContext(PluginManager.java:770)
at org.apache.maven.plugin.PluginManager.prepAttainGoal(PluginManager.java:725)
at org.apache.maven.plugin.PluginManager.attainGoals(PluginManager.java:656)
at org.apache.maven.MavenSession.attainGoals(MavenSession.java:263)
at org.apache.maven.cli.App.doMain(App.java:488)
at org.apache.maven.cli.App.main(App.java:1239)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.werken.forehead.Forehead.run(Forehead.java:551)
at com.werken.forehead.Forehead.main(Forehead.java:581)
You have encountered an unknown error running Maven. Please help us to correct
this problem by following these simple steps:
- read the Maven FAQ at http://maven.apache.org/faq.html
- run the same command again with the '-e' parameter, eg maven -e jar
As my application is using Maven1 and JDK1.4, I'm running eclipse:generate-classpath command.
I also tried to add xerces and xercesImpl jars via maven. Also added these two jars in C:\Dev\Jdks\jdk1.8.0_31\jre\lib\ext directory. Still getting the same error. Can anyone please help? I'll be greatful, Thanks in advance.
Hi everyone I am trying to create runnable jar file using Eclipse I am using two external libraries the first one is SWT library and the second one is opencv the application is working great in eclipse but once I try to export the jar file I received warnings:
and I get the following errors once I tried to run the jar file using the terminals by this command:
java -jar <name>.jar
I received the following errors:
***WARNING: Display must be created on main thread due to Cocoa restrictions.
org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(SWT.java:4491)
at org.eclipse.swt.SWT.error(SWT.java:4406)
at org.eclipse.swt.SWT.error(SWT.java:4377)
at org.eclipse.swt.widgets.Display.error(Display.java:1097)
at org.eclipse.swt.widgets.Display.createDisplay(Display.java:848)
at org.eclipse.swt.widgets.Display.create(Display.java:831)
at org.eclipse.swt.graphics.Device.<init>(Device.java:130)
at org.eclipse.swt.widgets.Display.<init>(Display.java:721)
at org.eclipse.swt.widgets.Display.<init>(Display.java:712)
at org.eclipse.swt.widgets.Display.getDefault(Display.java:1427)
at detectingApplication.gui_rec.<init>(gui_rec.java:42)
at detectingApplication.gui_rec.main(gui_rec.java:58)
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:497)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Any suggestions?
The 'Exported with compile warnings' messages mean some of your code does not compile cleanly. Eclipse should be showing you warnings about this (unless the warnings have been turned off).
When running on Mac OS X you must specify the -XstartOnFirstThread option on your java command to ensure the correct thread is used by SWT. This will fix the 'Display must be created on main thread due to Cocoa restrictions' error. This error is not related to the compile warnings messages.
I'm new with WSO2 products. I try WSO2 EMM and when I try to start emm 1.1.0 I get the following errors. I tried on Ubuntu, Debian and Windows and always the same issue.
It doesn't happen with the 1.0.0
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:622)
at org.wso2.carbon.bootstrap.Bootstrap.loadClass(Bootstrap.java:63)
at org.wso2.carbon.bootstrap.Bootstrap.main(Bootstrap.java:45)
Caused by: java.lang.RuntimeException: org.eclipse.core.runtime.adaptor.EclipseStarter
at org.wso2.carbon.server.CarbonLauncher.launch(CarbonLauncher.java:117)
at org.wso2.carbon.server.Main.launchCarbon(Main.java:163)
at org.wso2.carbon.server.Main.main(Main.java:95)
... 6 more
I already saw these errors but there was no answers.
Any ideas ?
Antoine
Ok, I answer to my own question, may be it could help...
It's still not working on linux, but it's now working on windows.
The only thing I did is ti strickly respect the folder name and structure
Let my explain:
When it was not working the structure of the folder was:
c:\wsoemm\bin...
now it's
c:\wso2\wsoeme-1.1.0\bin
This is the only thing I did to make it working
I would prefer running WSO2 EMM on linux so any help would be great.
Antoine
After 3 days it's now working on linux
you have to change the file null.ini wich is located at
/wherever you put the folder/wso2/wso2emm-1.1.0/repository/components/default
the default file is:
-install
/home/nira/git/EMM/product-emm/modules/p2-profile-gen/target/wso2carbon-core-4.2.0/repository/components/default
change it to:
-install
/wherever you put the folder/wso2/wso2emm-1.1.0/repository/components/default
That's it
I am using Ubuntu 14.04 with Oracle JDK 8. I want to inspect performance of my application using VisualVM. I can inspect other applications like JDownloader but I can't inspect my own applications and Eclipse 4.3. Before I made fresh install of Ubuntu, I was using JDK 7 and I have no problem and using it without any configuration. It gives following log.
SEVERE [org.openide.util.RequestProcessor]: Error in RequestProcessor com.sun.tools.visualvm.core.ui.DataSourceWindowManager$1
java.lang.IllegalArgumentException: Unexpected composite type for ThreadInfo
at sun.management.ThreadInfoCompositeData.validateCompositeData(ThreadInfoCompositeData.java:372)
at sun.management.ThreadInfoCompositeData.getInstance(ThreadInfoCompositeData.java:68)
at java.lang.management.ThreadInfo.<init>(ThreadInfo.java:263)
at java.lang.management.ThreadInfo.from(ThreadInfo.java:794)
Caused: 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:483)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
at com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory$CompositeBuilderViaFrom.fromCompositeData(DefaultMXBeanMappingFactory.java:1018)
Caused: java.io.InvalidObjectException: Failed to invoke from(CompositeData)
at com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory.invalidObjectException(DefaultMXBeanMappingFactory.java:1457)
at com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory$CompositeBuilderViaFrom.fromCompositeData(DefaultMXBeanMappingFactory.java:1021)
at com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory$CompositeMapping.fromNonNullOpenValue(DefaultMXBeanMappingFactory.java:919)
at com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory$NonNullMXBeanMapping.fromOpenValue(DefaultMXBeanMappingFactory.java:133)
at com.sun.jmx.mbeanserver.ConvertingMethod.fromOpenReturnValue(ConvertingMethod.java:131)
at com.sun.jmx.mbeanserver.MXBeanProxy.invoke(MXBeanProxy.java:168)
at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:252)
Caused: java.lang.reflect.UndeclaredThrowableException
at com.sun.proxy.$Proxy8.getThreadInfo(Unknown Source)
at com.sun.tools.visualvm.jmx.impl.JmxSupport.isReadOnlyConnection(JmxSupport.java:95)
at com.sun.tools.visualvm.jmx.impl.JmxModelImpl.isTakeThreadDumpSupported(JmxModelImpl.java:311)
at com.sun.tools.visualvm.application.views.threads.ApplicationThreadsViewProvider.resolveThreads(ApplicationThreadsViewProvider.java:65)
at com.sun.tools.visualvm.application.views.threads.ApplicationThreadsViewProvider.supportsViewFor(ApplicationThreadsViewProvider.java:29)
at com.sun.tools.visualvm.application.views.threads.ApplicationThreadsViewProvider.supportsViewFor(ApplicationThreadsViewProvider.java:25)
at com.sun.tools.visualvm.core.ui.DataSourceViewsManager.getViews(DataSourceViewsManager.java:116)
at com.sun.tools.visualvm.core.ui.DataSourceWindowManager.openWindowAndAddView(DataSourceWindowManager.java:169)
at com.sun.tools.visualvm.core.ui.DataSourceWindowManager.access$000(DataSourceWindowManager.java:30)
at com.sun.tools.visualvm.core.ui.DataSourceWindowManager$1.run(DataSourceWindowManager.java:80)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1393)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2005)
you should run visualvm on the same JDK version as your app, look at help->about->details (Java), mine was surprisingly jdk8 instead of jdk13 (I have both), so you can setup JDK version for visualvm manually etc/visualvm.conf, uncomment and setup parameter
visualvm_jdkhome=C:\Program Files\Java\jdk-13
run eclipse and your application with jvm parameters -Duser.language=en -Duser.country=us ...
then you will be able profile with jvisualvm.
for eclise put this two lines in eclipse.ini
-Duser.language=en
-Duser.country=us
maybe your pre installed Ubuntu had languge settings as english and you was ok.