7

我正在尝试在一个结合了 Java 和 C/JNI 代码的 Android 项目的测试中运行 Emma。构建和测试工作正常,但每当我添加时emma,我都会遇到一个神秘的异常。我正在使用 Android SDK v20.1 和 NDK r8b。

该项目在这里,它是一个 Android 库项目: https ://github.com/guardianproject/IOCipher ,测试在这里: https ://github.com/guardianproject/IOCipherTests

build.xml文件是使用生成的android update test-projectant clean debug install test每次运行都会ant clean emma debug install test触发异常:

这是一个例外:

-dex:
      [dex] Converting compiled files and external libraries into /var/lib/jenkins/workspace/IOCipherTests/IOCipherTests/bin/classes.dex...
       [dx] 
       [dx] EXCEPTION FROM SIMULATION:
       [dx] local variable type mismatch: attempt to set or access a value of type int using a local variable of type info.guardianproject.libcore.io.ErrnoException. This is symptomatic of .class transformation tools that ignore local variable information.
       [dx] 
       [dx] ...at bytecode offset 0000002e
       [dx] locals[0000]: Linfo/guardianproject/iocipher/File;
       [dx] locals[0001]: Linfo/guardianproject/iocipher/FileDescriptor;
       [dx] locals[0002]: <invalid>
       [dx] locals[0003]: <invalid>
       [dx] locals[0004]: <invalid>
       [dx] locals[0005]: [Z
       [dx] stack[top0]: int{0x00000001 / 1}
       [dx] ...while working on block 002c
       [dx] ...while working on method createNewFile:()Z
       [dx] ...while processing createNewFile ()Z
       [dx] ...while processing info/guardianproject/iocipher/File.class
       [dx] 
       [dx] 1 error; aborting
BUILD FAILED
/opt/android-sdk/tools/ant/build.xml:850: The following error occurred while executing this line:
/opt/android-sdk/tools/ant/build.xml:852: The following error occurred while executing this line:
/opt/android-sdk/tools/ant/build.xml:864: The following error occurred while executing this line:
/opt/android-sdk/tools/ant/build.xml:266: null returned: 1
4

2 回答 2

3

我遇到了同样的错误。在我的项目中,我们在一个项目中有一个单元测试应用程序,它包装了另一个包含单元测试本身的项目。这两个项目都引用了我的 SDK,正如 chaitanya 所建议的那样,这导致 emma 两次检测 SDK 代码。通过删除单元测试项目中对 SDK 的引用,我能够解决该错误。

于 2013-05-10T18:22:19.520 回答
0

我从命令行构建了 Android APK 项目(没有 ant,但在 CMake 的一些帮助下。我想这在这里并不重要)我遇到了同样的错误,有两件事帮助了我:

  1. 这里,我得到的信息是“如果您检测包含局部变量调试信息的类文件,艾玛无法正确维护局部变量表。当您尝试为 Android 转换类文件时,这将导致错误。解决方法为此,仅使用行和源调试信息而不是本地信息来编译 java 类。” ,所以我在java编译器中添加了一个标志-g:{lines,source}

  2. 我还将 Emma 类本身排除在检测之外。我的检测命令是java -cp emma/emma_device.jar emma instr -ix -*.test.*,-com.google.android.*,-com.vladium.* -m overwrite -cp ${CMAKE_JAVA_TARGET_OUTPUT_DIR}. 注意-ix -com.vladium.*参数,这不包括 Emma 类

于 2015-03-10T09:56:05.487 回答