SonarQube Scanner error when run "sonar-scanner" command - java

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

Related

Maven1.x: javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found

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.

How to resolve NoClassDefFoundError while using Hadoop?

I am getting
Exception in thread "main" java.lang.NoClassDefFoundError: com/linkedin/camus/etl/IEtlKey.
On running the command:
hadoop jar camus-etl-kafka-0.1.0-SNAPSHOT.jar
com.linkedin.camus.etl.kafka.CamusJob -P camus.properties
I am getting the below exceptions..
2016-04-27 11:34:04.622 java[13567:351959] Unable to load realm mapping info from SCDynamicStore
[NativeCodeLoader] - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Exception in thread "main" java.lang.NoClassDefFoundError: com/linkedin/camus/etl/IEtlKey
at com.linkedin.camus.etl.kafka.CamusJob.run(CamusJob.java:252)
at com.linkedin.camus.etl.kafka.CamusJob.run(CamusJob.java:235)
at com.linkedin.camus.etl.kafka.CamusJob.run(CamusJob.java:691)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:84)
at com.linkedin.camus.etl.kafka.CamusJob.main(CamusJob.java:646)
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:606)
at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Caused by: java.lang.ClassNotFoundException: com.linkedin.camus.etl.IEtlKey
I have included camus-example-0.1.0-SNAPSHOT-shaded.jar in the classpath .
Please let me know if I am missing something .
Thanks in Advance
Soumyajit
You should try to include camus-api you can find on this LinkedIn's previous generation Kafka to HDFS pipeline page, since the missing class is contained in this package, as you can see here.
Pay attention to other transitive dependencies that may be required by Camus.
In addition, to be sure that classes will be found in the classpath when you use the hadoop jar from command line, you can add the libjars command line option, as reported in Using the libjars option with Hadoop:
$ export LIBJARS=/path/jar1,/path/jar2
$ hadoop jar my-example.jar com.example.MyTool -libjars ${LIBJARS} -mytoolopt value
It could be useful to know that Camus is going to be superseded by Gobblin:
Camus is being phased out and replaced by Gobblin. For those using or
interested in Camus, we suggest taking a look at Gobblin.
For instructions on Migrating from Camus to Gobblin, please take
a look at Camus Gobblin Migration.

SONARCLIPS 3.5.0 Invalid value of sonar.libraries IllegalStateException: No files nor directories matching Eclipse Mars

Should a new "Invalid value of sonar.libraries / IllegalStateException: No files nor directories matching" defect be reported against the SONARCLIPS 3.5. Or should I try to get defect SONARCLIPS-430 already fixed in SonarQube Eclipse Plugin 3.5 re-opened?
In Eclipse Mars (4.5.0) when I try to use SonarQube Eclipse Plugin 3.5.0.20150804 to analyze a project, it fails with the error
Invalid value of sonar.libraries
and the caused by exception
IllegalStateException: No files nor directories matching [...]
According to SONARCLIPS-430, SonarQube Eclipse 3.5 fixed this issue. But I'm running 3.5 and still encountering the problem. I'm not using Groovy for this project and SONARCLIPS-430 resulted from the stackoverflow question about groovy and SonarQube Eclipse: Sonar Eclipse issue.
The sonar.libraries involved in this analysis is (copied from sonar-project2243985040659442672.properties):
sonar.libraries=C:\tool\Java\jdk1.8.0_51\jre\lib\resources.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\rt.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\jsse.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\jce.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\charsets.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\jfr.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\ext\access-bridge-64.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\ext\cldrdata.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\ext\dnsns.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\ext\jaccess.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\ext\jfxrt.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\ext\localedata.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\ext\nashorn.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\ext\sunec.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\ext\sunjce_provider.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\ext\sunmscapi.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\ext\sunpkcs11.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\ext\zipfs.jar,C:/dev/prodtrunk/someProduct/PhysView/PhysViewApi/target/classes,C:/dev/prodtrunk/someProduct/Configuration/ConfigurationStructure/target/classes,C:/dev/prodtrunk/someProduct/Configuration/ConfigurationStructure/target/test-classes,C:\mvnrepo\junit\junit\4.12\junit-4.12.jar,C:\mvnrepo\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar,C:\mvnrepo\log4j\log4j\1.2.17\log4j-1.2.17.jar,C:\mvnrepo\org\osgi\org.osgi.compendium\5.0.0\org.osgi.compendium-5.0.0.jar,C:\mvnrepo\org\osgi\org.osgi.core\5.0.0\org.osgi.core-5.0.0.jar,C:/dev/prodtrunk/someProduct/DeviceStructure/target/classes,C:/dev/prodtrunk/someProduct/DeviceStructure/target/test-classes,C:\mvnrepo\org\slf4j\slf4j-api\1.6.6\slf4j-api-1.6.6.jar,C:/dev/prodtrunk/JavaCommon/target/classes,C:/dev/prodtrunk/JavaCommon/target/test-classes,C:\mvnrepo\jython\jython\2.1\jython-2.1.jar,C:\mvnrepo\commons-codec\commons-codec\1.7\commons-codec-1.7.jar,C:\mvnrepo\commons-logging\commons-logging\1.1.1\commons-logging-1.1.1.jar,C:\mvnrepo\commons-cli\commons-cli\1.0\commons-cli-1.0.jar,C:/dev/prodtrunk/someProduct/Logging/Logging/target/classes,C:\mvnrepo\commons-lang\commons-lang\2.5\commons-lang-2.5.jar,C:\mvnrepo\commons-collections\commons-collections\3.2.1\commons-collections-3.2.1.jar,C:\mvnrepo\org\easymock\easymock\3.3.1\easymock-3.3.1.jar,C:\mvnrepo\cglib\cglib\3.1\cglib-3.1.jar,C:\mvnrepo\org\ow2\asm\asm\5.0.3\asm-5.0.3.jar,C:\mvnrepo\org\objenesis\objenesis\2.1\objenesis-2.1.jar,C:/dev/prodtrunk/someProduct/someProductCommon/target/classes,C:\mvnrepo\org\knopflerfish\bundle\desktop\5.0.1\desktop-5.0.1.jar,C:\mvnrepo\com\somecompany\someproduct\ActionProcessing\7.0.0.0-SNAPSHOT\ActionProcessing-7.0.0.0-SNAPSHOT.jar,C:/dev/prodtrunk/someProduct/CircuitManagement/CircuitStructure/target/classes,C:/dev/prodtrunk/someProduct/CircuitManagement/CircuitStructure/target/test-classes,C:/dev/prodtrunk/someProduct/JavaCommon_Bundle/target/classes,C:\mvnrepo\org\hibernate\hibernate-envers\3.6.4.Final\hibernate-envers-3.6.4.Final.jar,C:\mvnrepo\org\hibernate\hibernate-core\3.6.4.Final\hibernate-core-3.6.4.Final.jar,C:\mvnrepo\antlr\antlr\2.7.6\antlr-2.7.6.jar,C:\mvnrepo\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar,C:\mvnrepo\javax\transaction\jta\1.1\jta-1.1.jar,C:\mvnrepo\org\hibernate\hibernate-commons-annotations\3.2.0.Final\hibernate-commons-annotations-3.2.0.Final.jar,C:\mvnrepo\org\hibernate\hibernate-entitymanager\3.6.4.Final\hibernate-entitymanager-3.6.4.Final.jar,C:\mvnrepo\cglib\cglib\2.2\cglib-2.2.jar,C:\mvnrepo\asm\asm\3.1\asm-3.1.jar,C:\mvnrepo\javassist\javassist\3.12.0.GA\javassist-3.12.0.GA.jar,C:\mvnrepo\org\hibernate\hibernate-tools\3.2.0.ga\hibernate-tools-3.2.0.ga.jar,C:\mvnrepo\org\beanshell\bsh\2.0b4\bsh-2.0b4.jar,C:\mvnrepo\freemarker\freemarker\2.3.8\freemarker-2.3.8.jar,C:\mvnrepo\org\hibernate\jtidy\r8-20060801\jtidy-r8-20060801.jar,C:\mvnrepo\org\hibernate\javax\persistence\hibernate-jpa-2.0-api\1.0.0.Final\hibernate-jpa-2.0-api-1.0.0.Final.jar,C:/dev/prodtrunk/someProduct/DatabaseCommon/target/classes,C:/dev/prodtrunk/someProduct/LegacyCommunicationsApi/target/classes,C:/dev/prodtrunk/someProduct/Automation/automation-common/target/classes,C:/dev/prodtrunk/someProduct/DSLink_bundle/target/classes,C:\mvnrepo\org\iot-dsa\dslink\0.8.0\dslink-0.8.0.jar,C:\mvnrepo\org\iot-dsa\logging\0.8.0\logging-0.8.0.jar,C:\mvnrepo\org\iot-dsa\runtime_shared\0.8.0\runtime_shared-0.8.0.jar,C:\mvnrepo\io\vertx\vertx-core\2.1.5\vertx-core-2.1.5.jar,C:\mvnrepo\com\fasterxml\jackson\core\jackson-databind\2.2.2\jackson-databind-2.2.2.jar,C:\mvnrepo\com\fasterxml\jackson\core\jackson-annotations\2.2.2\jackson-annotations-2.2.2.jar,C:\mvnrepo\com\fasterxml\jackson\core\jackson-core\2.2.2\jackson-core-2.2.2.jar,C:\mvnrepo\io\netty\netty-all\4.0.21.Final\netty-all-4.0.21.Final.jar,C:\mvnrepo\com\beust\jcommander\1.48\jcommander-1.48.jar,C:\mvnrepo\org\bouncycastle\bcprov-jdk15on\1.51\bcprov-jdk15on-1.51.jar,C:/dev/prodtrunk/someProduct/someProductSystem/someProductSystemApi/target/classes,C:/dev/prodtrunk/PersistenceService/PersistenceService/target/classes,C:/dev/prodtrunk/PersistenceService/PersistenceService/target/test-classes,C:/dev/prodtrunk/ServiceManagement/ServiceManagement/target/classes,C:/dev/prodtrunk/SecretStuff/SecretStuff/target/classes,C:/dev/prodtrunk/SecretStuff/SecretStuff/target/test-classes,C:\mvnrepo\com\somecompany\someproduct\communication\Communication\7.0.0.0-SNAPSHOT\Communication-7.0.0.0-SNAPSHOT.jar,C:\mvnrepo\org\jacorb\jacorb\3.1\jacorb-3.1.jar,C:\mvnrepo\tanukisoft\wrapper\3.5.4\wrapper-3.5.4.jar,C:\mvnrepo\com\sun\xml\bind\jaxb-impl\2.1.5\jaxb-impl-2.1.5.jar,C:\mvnrepo\javax\xml\bind\jaxb-api\2.1\jaxb-api-2.1.jar,C:\mvnrepo\javax\activation\activation\1.1\activation-1.1.jar,C:\mvnrepo\javax\xml\stream\stax-api\1.0-2\stax-api-1.0-2.jar,C:\mvnrepo\org\slf4j\slf4j-log4j12\1.6.6\slf4j-log4j12-1.6.6.jar,C:/dev/prodtrunk/someProduct/Faults/FaultServiceApi/target/classes,C:/dev/prodtrunk/someProduct/Persistence/target/classes,C:\mvnrepo\org\knopflerfish\bundle\remoteserviceadmin-API\1.0.0\remoteserviceadmin-API-1.0.0.jar,C:\mvnrepo\javax\servlet\servlet-api\2.4\servlet-api-2.4.jar,C:/dev/prodtrunk/someProduct/Automation/automation-service/target/classes,C:/dev/prodtrunk/someProduct/Automation/automation-service/target/test-classes,C:/dev/prodtrunk/someProduct/Configuration/ConfigurationManagement/target/classes,C:\mvnrepo\org\hibernate\hibernate-c3p0\3.6.4.Final\hibernate-c3p0-3.6.4.Final.jar,C:\mvnrepo\c3p0\c3p0\0.9.1\c3p0-0.9.1.jar,C:/dev/prodtrunk/someProduct/Hibernate/target/classes,C:\mvnrepo\org\postgresql\postgresql\9.2-1003-jdbc4\postgresql-9.2-1003-jdbc4.jar,C:\mvnrepo\mysql\mysql-connector-java\5.1.12\mysql-connector-java-5.1.12.jar,C:\mvnrepo\org\codehaus\groovy\groovy-all\2.0.2\groovy-all-2.0.2.jar,C:/dev/prodtrunk/someProduct/LegacyCommunications/target/classes,C:/dev/prodtrunk/someProduct/LegacyCommunications/target/test-classes,C:/dev/prodtrunk/someProduct/PanelManager/target/classes,C:/dev/prodtrunk/someProduct/PanelManager/target/test-classes,C:\mvnrepo\org\knopflerfish\bundle\console\4.0.1\console-4.0.1.jar,C:\mvnrepo\org\knopflerfish\log-API\5.0.0\log-API-5.0.0.jar,C:/dev/prodtrunk/someProduct/Users/UserServiceApi/target/classes,C:/dev/prodtrunk/someProduct/TerminalArbitration/terminalarbitration-common/target/classes,C:/dev/prodtrunk/someProduct/SecretStuffService/target/classes,C:\mvnrepo\com\eclipsesource\jaxrs\publisher\5.0\publisher-5.0.jar,C:\mvnrepo\com\eclipsesource\jaxrs\jersey-all\2.18\jersey-all-2.18.jar
The full exception emitted is
08:57:06.276 ERROR - Invalid value of sonar.libraries for com.somecompany.someproduct.physview:PhysViewImpl
Exception in thread "main" org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.impl.BatchLauncherMain.execute(BatchLauncherMain.java:41)
at org.sonar.runner.impl.BatchLauncherMain.main(BatchLauncherMain.java:59)
Caused by: java.lang.IllegalStateException: No files nor directories matching 'C:/dev/prodtrunk/someProduct/Configuration/ConfigurationStructure/target/test-classes' in directory C:\dev\prodtrunk\someProduct\PhysView\PhysViewImpl
at org.sonar.batch.scan.ProjectReactorBuilder.validateDirectories(ProjectReactorBuilder.java:302)
at org.sonar.batch.scan.ProjectReactorBuilder.defineProject(ProjectReactorBuilder.java:131)
at org.sonar.batch.scan.ProjectReactorBuilder.execute(ProjectReactorBuilder.java:114)
at org.sonar.batch.scan.ProjectScanContainer.projectBootstrap(ProjectScanContainer.java:114)
at org.sonar.batch.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:92)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:90)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:64)
at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:51)
at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:110)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
at org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapContainer.java:185)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
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.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
... 6 more
Julien's comment led to the answer. For some reason, we had a maven project with an empty src/test/java. Once, I deleted src/test and src/java, the error went away.

how to configure simply android studio to run JUnit tests

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/

Unity-Android _ CommandInvokationFailure: Unable to convert classes into dex format

i'm using Windows 7, jdk 1.8.0 (64bit), jre 8 (64bit), Unity Pro 4.3.4f1 and Android SDK 22.6.1
All are updated softwares.
All works fine but when i use StartApp sdk, this error comes. No extra plugin is used, only the SDK provided by the StartApp ad.
Error building Player: CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.
C:\Program Files\Java\jdk1.8.0\bin\java.exe -Xmx1024M -Dcom.android.sdkmanager.toolsdir="D:/android-sdks\tools" -Dfile.encoding=UTF8 -jar "C:/Program Files (x86)/Unity/Editor/Data/BuildTargetTools/AndroidPlayer\sdktools.jar" -
stderr[
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/unity3d/player/a$1;
at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
at com.android.dx.command.dexer.Main.processClass(Main.java:685)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
at com.android.dx.command.dexer.Main.access$600(Main.java:78)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
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 SDKMain.main(SDKMain.java:129)
1 error; aborting
]
I already tried JAVA_OPT and JAVA_HOME solutions. But still couldn't solved
I ran into this using IntelliJ 13.1.4, JDK 1.6 but I would guess that this is caused by the same thing on any other IDE -> classes.jar is referenced/included more than once.
Check and make sure that the classes.jar you added to the project (from Unity\Editor\Data\PlaybackEngines\androidplayer\bin\classes.jar) isn't referenced/included more than once. If you go into File->Project Structure:
There should only be one "classes" under libraries.
There should be NO reference to classes under Artifacts (Artifacts is used to create the plugin .jar file.)
Check out this related answer ->
https://stackoverflow.com/a/8437996/3464367
My issue was actually related to having duplicate files. Well not really duplicates, but I had 2 adMob sdk packages (different versions), that were getting into conflict. After deleting the older one, everything was fixed. Are you using any 3rd party SDK's or something similar, if so, try removing them if possible and see if the issue persists. Try to find out which part of the code is causing this to happen. You could ultimately try to compile an empty project just for testing.
Today I solved similar problem of Error building Player: CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details. with adding .jar file into Plugins\Android\
I got different kind of errors:
Caused by: com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000 ...
Caused by: com.android.dx.cf.iface.ParseException: class name (ht/stringing/test) does not match path (src/ht/stringing/test.class)
My result working solution was similar to this:
Code lives here:
verysimple\src\ht\stringing\test.java
I do:
> javac -classpath "c:\Android\sdk\platforms\android-15" ht\stringing\test.java
> jar cvf ..\dist\verysimple.jar ht\stringing\test.class
> copy ..\dist\verysimple.jar c:\ExUnityApp\Assets\Plugins\Android
Don't forget to compare your 'Minimum Api Level' in Player Setting. For me it was Android 4.0.3 ... (15)

Categories

Resources