我正在使用Juniversal将Java转换为Objective-C和C#
此外,JUnit已添加到Android项目(jar文件,gradle)
当我使用Mac OSX(Yosemite)终端运行命令时:
java -jar juniversal/juniversal-translator/build/libs/juniversal-translator-0.8.3.jar -o $OBJC_OUTPUT -l c# -classpath jsimple/libraries/jsimple-util/build/libs/jsimple-util-0.9.3.jar -sourcepath $HOME/androidstudioprojects/testbuild/app/src/main/java $HOME/androidstudioprojects/testbuild/app/src/test/java
显示错误:
/Users/emaar/AndroidStudioProjects/TestBuild/app/src/test/java
Error: The import org.junit cannot be resolved
File /Users/emaar/AndroidStudioProjects/TestBuild/app/src/test/java/com/emaar/app/testbuild/ExampleUnitTest.java
3:7: import org.junit.Test;
^
Error: The import org.junit cannot be resolved
File /Users/emaar/AndroidStudioProjects/TestBuild/app/src/test/java/com/emaar/app/testbuild/ExampleUnitTest.java
5:14: import static org.junit.Assert.*;
^
Error: Test cannot be resolved to a type
File /Users/emaar/AndroidStudioProjects/TestBuild/app/src/test/java/com/emaar/app/testbuild/ExampleUnitTest.java
11:5: @Test
^
Error: The method assertEquals(int, int) is undefined for the type ExampleUnitTest
File /Users/emaar/AndroidStudioProjects/TestBuild/app/src/test/java/com/emaar/app/testbuild/ExampleUnitTest.java
13:8: assertEquals(4, 2 + 2);
^
Translating /Users/emaar/AndroidStudioProjects/TestBuild/app/src/test/java/com/emaar/app/testbuild/ExampleUnitTest.java
org.juniversal.translator.core.JUniversalException: null
Error occurred with context at position
File /Users/emaar/AndroidStudioProjects/TestBuild/app/src/test/java/com/emaar/app/testbuild/ExampleUnitTest.java
13:8: assertEquals(4, 2 + 2);
^
at org.juniversal.translator.core.SourceFileWriter.writeRootNode(SourceFileWriter.java:120)
at org.juniversal.translator.csharp.CSharpTranslator.translateFile(CSharpTranslator.java:60)
at org.juniversal.translator.core.Translator$1.acceptAST(Translator.java:239)
at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:1029)
at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:636)
at org.eclipse.jdt.core.dom.ASTParser.createASTs(ASTParser.java:990)
at org.juniversal.translator.core.Translator.translate(Translator.java:247)
at org.juniversal.translator.core.Translator.translate(Translator.java:87)
at org.juniversal.translator.core.Translator.main(Translator.java:50)
Caused by: java.lang.NullPointerException
at org.juniversal.translator.csharp.MethodInvocationWriterBase.writeMethodInvocation(MethodInvocationWriterBase.java:50)
at org.juniversal.translator.csharp.MethodInvocationWriter.write(MethodInvocationWriter.java:33)
at org.juniversal.translator.csharp.MethodInvocationWriter.write(MethodInvocationWriter.java:27)
at org.juniversal.translator.core.SourceFileWriter.writeNode(SourceFileWriter.java:98)
at org.juniversal.translator.core.ASTNodeWriter.writeNode(ASTNodeWriter.java:42)
at org.juniversal.translator.csharp.CSharpSourceFileWriter$11.write(CSharpSourceFileWriter.java:304)
at org.juniversal.translator.csharp.CSharpSourceFileWriter$11.write(CSharpSourceFileWriter.java:301)
at org.juniversal.translator.core.SourceFileWriter.writeNode(SourceFileWriter.java:98)
at org.juniversal.translator.core.ASTNodeWriter.writeNode(ASTNodeWriter.java:42)
at org.juniversal.translator.csharp.MethodDeclarationWriter.lambda$writeBody$17(MethodDeclarationWriter.java:336)
at org.juniversal.translator.csharp.MethodDeclarationWriter$$Lambda$10/146370526.accept(Unknown Source)
at org.juniversal.translator.core.ASTUtil.forEach(ASTUtil.java:530)
at org.juniversal.translator.csharp.MethodDeclarationWriter.writeBody(MethodDeclarationWriter.java:327)
at org.juniversal.translator.csharp.MethodDeclarationWriter.write(MethodDeclarationWriter.java:164)
at org.juniversal.translator.csharp.MethodDeclarationWriter.write(MethodDeclarationWriter.java:35)
at org.juniversal.translator.core.SourceFileWriter.writeNode(SourceFileWriter.java:98)
at org.juniversal.translator.core.ASTNodeWriter.writeNode(ASTNodeWriter.java:42)
at org.juniversal.translator.csharp.TypeDeclarationWriter.lambda$write$23(TypeDeclarationWriter.java:107)
at org.juniversal.translator.csharp.TypeDeclarationWriter$$Lambda$3/518522822.accept(Unknown Source)
at org.juniversal.translator.core.ASTUtil.forEach(ASTUtil.java:520)
at org.juniversal.translator.csharp.TypeDeclarationWriter.write(TypeDeclarationWriter.java:105)
at org.juniversal.translator.csharp.TypeDeclarationWriter.write(TypeDeclarationWriter.java:32)
at org.juniversal.translator.core.SourceFileWriter.writeNode(SourceFileWriter.java:98)
at org.juniversal.translator.core.ASTNodeWriter.writeNode(ASTNodeWriter.java:42)
at org.juniversal.translator.csharp.CompilationUnitWriter.writeNamespaceAndTypeDeclaration(CompilationUnitWriter.java:175)
at org.juniversal.translator.csharp.CompilationUnitWriter.write(CompilationUnitWriter.java:54)
at org.juniversal.translator.csharp.CompilationUnitWriter.write(CompilationUnitWriter.java:41)
at org.juniversal.translator.core.SourceFileWriter.writeNode(SourceFileWriter.java:98)
at org.juniversal.translator.core.SourceFileWriter.writeRootNode(SourceFileWriter.java:112)
... 8 more
如何修复?